cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
KyleJ
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
v-siky-msft
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
v-siky-msft
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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (44,680)