Implementing "|| & ," in Filtering in Power Apps

 

Another filtering nuance i ran into today was how to implement Logical filters in Power Apps.

You will find different blog posts and videos on how to implement multiple filter in Power Apps, but there isn't much showing how to implement logical filters in PowerApps. 

From outset this is quiet a simple case. 

Scenario: i have 3 people picker controls in my SharePoint list. Lets name them Project Manager, Sponsor and Follow Project.

Now when i open my dashboard i want to see projects filtered based on these three fields. Like if a person's name is present in either Project manager, Sponsor or Follow Project fields he/ she will be seeing the project.

Solution:  First of all People picker controls are still a pain in PowerApps, by pain i mean they are still treated as a complex field, filtering, delegation and controls fail to respond on using them. So what we will do is create 3 single line textbox fields in Sharepoint. 

Then we will refresh the data source in power apps, so that all three are added in our App. Now we need to add these fields on our form and update the Default property of these fields to respective people picker fields.

Default = ddProjectManager.Selected.Email

where ddProjectManager is the DataCardValue for the Project Manager People picker control.



Next is where the magic happens, the dashboard. Now what we want here is the gallery to load items with our custom filtering logic.

So what we do next is apply filtering on Items Property of gallery in our app.

Filter(

    Projects,

    PM_Email = varUser.Email || Sponsor_Email = varUser.Email || FollowProject_Email = varUser.Email

)

What drove me bonkers was i was trying something like nested filtering. and then something like below

Filter(

    Projects,

    PM_Email = varUser.Email , Sponsor_Email = varUser.Email , FollowProject_Email = varUser.Email

)

If you replace "||" with "," in the above formula your OR operator becomes AND. and this changes the whole logic. 



I also tried the search function something like this

Search(Projects, varUser.Email, Project Managers, Sponsors, FollowProject)

where Projects is my data source, varUser is nothing but User() and rest are my sharepoint people picker controls.

The above function gave an error, told you before people picker are a pain. So i decided to try it with the single line text columns, remember the ones we created at the start.

Search(Projects, varUser.Email, "PM_Email", "Sponsors_Email", "FollowProject_Email")

This works fine but gives you a delegation warning. So if your list has more items or can have more items better to stick to the lovely Filter function. Just minding the "|| & ,"

Here is the reference article i referred when digging myself out of it.

https://jobs.collab365.community/delegation-of-filtering-and-search-data-in-powerapps/

Later
T

Comments

Popular posts from this blog

Creating Nested Galleries in Power Apps. (Parent-Child Relationship)

How to reset a datepicker control in PowerApps?

Reset () function failing to work on Edit form for Combo boxes in Power App.