Hi
I’m new to building PowerApps and programming. So, I hope there is a patient person there can help me with applying a filter to my gallery.
My app is created against SharePoint list.
I have 2 screens in my app.
Screen 1 – is the start screen with 4 buttons. Each button navigates to the same gallery on screen 2, but with a unique value. (“varStatus”, “varAssignTo” and “varReportedBy”) The 4th and last button navigates to the gallery and have to show “All issues”
I have tried to build a filter, but with no luck.
I can someone give me some pointers/directions on how to solve my filter issue?
Br
Solved! Go to Solution.
@mgs78 cool
looking at your buttons you can add those to a gallery with the following table which will make things a bit easier.
Step 1 - create buttons in gallery
add a gallery and set the Items to the code
Table(
{id:0, name: "Create new task"},
{id:1, name: "View new task"},
{id:2, name: "My tasks"},
{id:3, name: "All task"},
{id:4, name: "Reported ny me"}
)
Add a button to the gallery and set the text = Thisitem.name //name is not something i use so just to illustrate the functionality 😉
Result
Now we have buttons, lets do something with them
I will create a datasource for illustration as below (this will be your datasource in your case)
ClearCollect(
someDataToAbuse,
ForAll(
Sequence(20),
{
id:Value,
name:"name: " & Mod(Value,3),
status:Mod(Value,5) = 0,
assignedTo:If(Mod(Value,4) = 0,"me","someone else")
}
)
)
Result
Step 2
when i click on new task i want to see all the all records with the name = "name: 0" //same as you want to filter a column with a specific text
my tasks, i want to see all the assignedTo = "me"
all tasks, i want to see everything.
to get to this select the OnSelect of the gallery that you created for the buttons in step 1.
we going to create a filtered collection and assign that you you gallery, this will be the gallery on your second screen.
ClearCollect(colFiltered,
Switch(true,
ThisItem.id = 1, Filter(someDataToAbuse, name = "name: 0"), //same as your new task for example
ThisItem.id = 2, Filter(someDataToAbuse, assignedTo = "me"), //same as your my tasks for example
ThisItem.id = 3, someDataToAbuse //same as your all tasks
)
);
//navigate to your screen will go here
Result
You can can add function to the OnSelect for "create new task" and "re[ported by me" by using the id.
Hope it helps,
R
Hi @mgs78 - there is similar query answered. Take a look :
Solved: How to display a column within a PowerApps Gallery... - Power Platform Community (microsoft....
If, it's different from what you need to solve than share below info : What does "All Issues" refer - All the columns or just single column? Data type of column to filter?
Thanks for your reply but I think it is too advanced for what I want.
I have attached screenshots of my app which I hope can help explain what I mean.
When I click on the "View new tasks" button on screen 1, the user must navigate to screen 2 and the gallery must be filtered so it is only items with status "New" there are displayed.
@mgs78 - Now, i could understood your query much better, thanks for screenshots.
You can achieve the gallery filtration using variables.
Steps :
1. Define a filter variable at 'On Start' of app
Set(Filtervar, Blank())
2. Now, go to the button and on 'On Select' property
Navigate(Screen1_1); // Screen to navigate
Set(Filtervar,"Title1") // Set the filter var e.g. "New" (if you are filtering using Status)
3. Change Items property of Gallery -
Filter(
SharePointListName,
ColumntoFilter = Blank() Or ColumntoFilter = Filtervar)
PS : you can use Or function to filter out using multiple columns.
In my case, i defined filtervar on 'On Start' of app
than on Screen 1 - on select property of Button
Than 'Items' property of gallery on next screen
i hope this helps.
Hi AJ_vizMan
I'm (we) almost there 🙂
I have set the APP OnStart to Set(varStatus, Blank()); Set(varAssignTo, Blank()); Set(varReportedBy, Blank())
I have set the buttons to:
Button 1: Set(varStatus, "Not started"); Navigate(AllTasks,None)
Button 2: Set(varAssignTo, User().Email); Navigate(AllTasks,None)
Button 3: Set(varReportedBy, User().Email); Navigate(AllTasks,None)
And I have made the gallery filter as this:
SortByColumns(Filter('SP-VEDLTasks', Status.Value = varStatus Or 'Reported By'.Email=varReportedBy Or 'Assigned To'.Email=varAssignTo),"ID", Descending)
BUT I'm not getting the expected result - there are to many records. Can you see want I have done wrong?
Hi @mgs78
I would solve this with a collection that is filled depending on the button you pressed:
Button1: Set(varStatus, "Not started"); ClearCollect(myCollection,SortByColumns(Filter('SP-VEDLTasks', Status.Value = varStatus),"ID", Descending); Navigate(AllTasks,None)
Button2: Set(varReportedBy, User().Email); ClearCollect(myCollection,SortByColumns(Filter('SP-VEDLTasks', 'Reported By'.Email=varReportedBy),"ID", Descending); Navigate(AllTasks,None)
Button3: Set(varAssignTo, User().Email); ClearCollect(myCollection,SortByColumns(Filter('SP-VEDLTasks', 'Assigned To'.Email=varAssignTo),"ID", Descending); Navigate(AllTasks,None)
Then in the AllTasks screen you can set your gallery's items to myCollection.
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item.
If the content was useful in other ways, please consider giving it Thumbs Up.
Hi @uwenagel
I have not worked with Collection before - can you help me define the collection and be mere specific on how to write code at gallery?
Hi @uwenagel
I figured out how to use the collection, but it leave me with 2 other issues.
1. How to make button that show all items in the gallery.
2. How to make search (StartsWith...) field on the screen with the gallery
Can you also help me with these challenges?
hi @mgs78 you have been exposed to a few options, do you mind another one?
User | Count |
---|---|
256 | |
107 | |
90 | |
51 | |
44 |