cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper II
Helper II

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
Community Support
Community Support

@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
Community Support
Community Support

@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

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

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

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

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (53,087)