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

Trying to filter a gallery based on a people-picker dropdown with multiple selections.

Currently,

I have 3 inputs and a gallery on a screen. the first input is a people picker, the second is a drop-down choice of 2 items, and the third is a date picker. 

I have a gallery at the bottom. 

 

the gallery is filtered out by the selections in the top 3 filters. It can filter by person, and if option 1 or 2 is selected from the choices it can further filter, and then if a date is selected, it will also further filter.

 

The code for the each of the 3 inputs is as follows: 

 

PeoplePicker:

 

If(
IsBlank(FormulaBox1.Selected) = true,
UpdateContext({switch1Value: "0"}),
UpdateContext({switch1Value: "1"})
);
UpdateContext({switchValue: Concatenate(switch1Value, switch2Value , switch3Value)})

 

Branch/CPM Options:

 

If(
    IsBlank(FormulaBox2.Selected) = true,
    UpdateContext({switch2Value: "0"}),
    UpdateContext({switch2Value: "1"})
);
UpdateContext({switchValue: Concatenate(switch1Value,  switch2Value , switch3Value)})

 

Pay Period:

 

If(
    IsBlank(FormulaBox3.SelectedDate) = true,
    UpdateContext({switch3Value: "0"}),
    UpdateContext({switch3Value: "1"})
);
UpdateContext({switchValue: Concatenate(switch1Value,  switch2Value , switch3Value)})

 

And Finally, the Gallery Items that put it all together:  

 

Switch(
    switchValue,
    "000",currentCPMErrors,
    "100",Filter(currentCPMErrors, whoMadeError.DisplayName=FormulaBox1.Selected.DisplayName),
    "010",Filter(currentCPMErrors, branchOrCPMError.Value=FormulaBox2.Selected.Value),
    "001",Filter(currentCPMErrors, payPeriodOfError=FormulaBox3.SelectedDate),
    "110",Filter(currentCPMErrors, whoMadeError.DisplayName=FormulaBox1.Selected.DisplayName,branchOrCPMError.Value=FormulaBox2.Selected.Value),
    "011",Filter(currentCPMErrors, branchOrCPMError.Value=FormulaBox2.Selected.Value,payPeriodOfError=FormulaBox3.SelectedDate),
    "101",Filter(currentCPMErrors, whoMadeError.DisplayName=FormulaBox1.Selected.DisplayName,payPeriodOfError=FormulaBox3.SelectedDate),
    "111",Filter(currentCPMErrors,whoMadeError.DisplayName=FormulaBox1.Selected.DisplayName,branchOrCPMError.Value=FormulaBox2.Selected.Value, payPeriodOfError=FormulaBox3.SelectedDate),
    Filter(currentCPMErrors,whoMadeError.DisplayName="Cam Brennan")
)

 

 

(Finally my question)

If i make the people picker allow multiple selections, how can i let the code adapt to apply And(selectedItem1, selectedItem2, etc..) to the filter, only if more than 1 person is selected.

 

For testing purposes, i have been playing with strictly the "100" result of the switch value. I am not including any of the other filtering options UNTIL i have "100" working as expected" 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Trying to filter a gallery based on a people-picker dropdown with multiple selections.

@KyleJ,

 

To filter by multi-selection person combobox. you can try this 

 

Filter(currentCPMErrors, whoMadeError.Email in FormulaBox1.SelectedItems.Email)

 

However, there is a delegation error, because 'In' operator is not delegable in SharePoint. so my workaround is to add a gallery to show all records of 'currentCPMErrors' list, and use Gallery.AllItems instead of 'currentCPMErrors' list to avoid delegation error. Then the formulas should be like this:

 

Filter(Gallery.AllItems, whoMadeError.Email in FormulaBox1.SelectedItems.Email)

 

Note: If there is no need to display the gallery, you can just set the Visible to false.

Snipaste_2020-01-17_15-55-11.png

Sik

View solution in original post

2 REPLIES 2
Highlighted
Community Support
Community Support

Re: Trying to filter a gallery based on a people-picker dropdown with multiple selections.

@KyleJ,

 

To filter by multi-selection person combobox. you can try this 

 

Filter(currentCPMErrors, whoMadeError.Email in FormulaBox1.SelectedItems.Email)

 

However, there is a delegation error, because 'In' operator is not delegable in SharePoint. so my workaround is to add a gallery to show all records of 'currentCPMErrors' list, and use Gallery.AllItems instead of 'currentCPMErrors' list to avoid delegation error. Then the formulas should be like this:

 

Filter(Gallery.AllItems, whoMadeError.Email in FormulaBox1.SelectedItems.Email)

 

Note: If there is no need to display the gallery, you can just set the Visible to false.

Snipaste_2020-01-17_15-55-11.png

Sik

View solution in original post

Frequent Visitor

Re: Trying to filter a gallery based on a people-picker dropdown with multiple selections.

WOW I was trying some complicated things and using ForAll and getting nowhere...and yet that was so simple..thanks lol. 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (4,934)