cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

User metadata for filtering

Hi all,

 

we are building an app where user has access to items in the list based on its 'metadata' from another list. A simplified model:

 

Sharepoint list 1 (Users): username, email, DEPARTMENT, ...

Sharepoint list 2 (Items): Item name, amount, DEPARTMENT

 

User can belong to more departments. In this case he will have more records in List 1.

We need to load her department/s into an array(?) and use these values in Filter formula.

 

Q1: Should we load department value into some global variable? There can be more than one.

Q2: I haven't found a way how to Filter() on more than one value, is is possible?

 

 

thanks a lot for answering these newbie questions!

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
Community Support

Hi @milosha ,

What is the field type of department column? I assume it is Text, and you want to filter out all items belong to Department A and B.

In general, we can use 'In' operator to filter by multi-value, such as Filter(Users, Department in ["Department A", "Department B"]), then the gallery will show all items belong to Department A and B. But there is a delegation warning, because 'In' operator is not delegable for SharePoint in PowerApps,

If you want to avoid delegation warning, you can try this workaround, use ForAll function to iterate over the record of Table(["Department A", "Department B"]), collect each record that meets the '=' condition. 

1. add a combo box to select departments, set items property: 

 

Distinct(Users. Department)

 

2. set OnChange property of combobox as below to store all records meet the filter condition to collection.

 

Clear(MyCollection);ForAll(ComboBox1.SelectedItems,Collect(MyCollection,Filter(Users,Department = Result)))

 

3. set Items property of gallery to MyCollection

Snipaste_2020-01-08_17-12-53.png

Sik

View solution in original post

2 REPLIES 2
Super User
Super User

Here's a sample that uses multiple conditions in a FIlter()

Filter(CustomGallerySample,"Lorem ipsum 1" in SampleHeading,"Lorem ipsum dolor sit" in SampleText)
Community Support
Community Support

Hi @milosha ,

What is the field type of department column? I assume it is Text, and you want to filter out all items belong to Department A and B.

In general, we can use 'In' operator to filter by multi-value, such as Filter(Users, Department in ["Department A", "Department B"]), then the gallery will show all items belong to Department A and B. But there is a delegation warning, because 'In' operator is not delegable for SharePoint in PowerApps,

If you want to avoid delegation warning, you can try this workaround, use ForAll function to iterate over the record of Table(["Department A", "Department B"]), collect each record that meets the '=' condition. 

1. add a combo box to select departments, set items property: 

 

Distinct(Users. Department)

 

2. set OnChange property of combobox as below to store all records meet the filter condition to collection.

 

Clear(MyCollection);ForAll(ComboBox1.SelectedItems,Collect(MyCollection,Filter(Users,Department = Result)))

 

3. set Items property of gallery to MyCollection

Snipaste_2020-01-08_17-12-53.png

Sik

View solution in original post

Helpful resources

Announcements
secondImage

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

Top Kudoed Authors
Users online (36,673)