cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Izzet7
New Member

Filtering a gallery with a combobox, dropdown box and toggle

Hey,

Hoping someone can shed some light on this as I'm racking my brain!

 

I've a gallery that uses a combobox as a filter, however I'm looking to add another dropdown and a toggle but my brain is broken!

 

My code for the Items gallery is:

 

 

SortbyColumns(
If(
IsBlank(UserComboBox.Selected.DisplayName),
Filter(
UsersItemRequest,
Status <> "Rejected" && Status <> "Returned"
),
Filter(
UsersItemRequest,
Title in UserComboBox.Selected.DisplayName && Status <> "Rejected" && Status <> "Returned"
)
),
"Title",
Ascending
)

 

 

Which works for the usercombobox and shows all items if nothing selected, but I want the toggle to show only loan items (IsLoanItem = true) by default, and show everything if toggled off - for both if just a user is selected in usercombobox and/or if an item is selected in itemdropdownbox_3.

 

The dropdown is ItemDropdownBox_3 and the toggle is Toggle1_1.

 

My apologies if my explanation is awful! But thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
StalinPonnusamy
Community Champion
Community Champion

Hi @Izzet7 

 

With(
    {wCode: UsersItemRequest},
    Sort(
        Filter(
            wCode,
            (IsBlank(UserComboBox.SelectedItems) || IsEmpty(UserComboBox.SelectedItems) || UserComboBox.Selected.DisplayName in Title) 
&& (Toggle1_1.Value = false || IsLoanItem = Toggle1_1.Value) 
&& (IsBlank(ItemDropdownBox_3.Selected) || Item = ItemDropdownBox_3.Selected.Value)
        ),
        Title,
        Ascending
    )
)

 

To test this filter, add filter one by one and we can see the difference.

 

Sample

StalinPonnusamy_0-1634329905363.png

 

 

 

 

 

View solution in original post

5 REPLIES 5
StalinPonnusamy
Community Champion
Community Champion

Hi @Izzet7 

 

With(
    {wCode: Filter(UsersItemRequest,Status <> "Rejected" && Status <> "Returned")},
    Sort(
        Filter(
            wCode,
            (IsEmpty(UserComboBox.SelectedItems) || Title in UserComboBox.Selected.DisplayName) &&
	    (IsBlank(ItemDropdownBox_3.Selected) || Item = ItemDropdownBox_3.Selected.Value) &&
	    IsLoanItem = Toggle1_1.Value
        ),
Title,
Ascending
    )
)

 

Not sure which field you want to filter for ItemDropdownBox_3 so I put Item. Replace with field name

 

Thanks @StalinPonnusamy, though it's not quite what I need, I'll try and explain better;

 

I need the gallery by default to show EVERYTHING in UsersItemRequest, with the toggle being able to switch from showing Loaned Items (toggled on) or All items (toggled off).

 

Then I need my Gallery to be filtered by Users alone if something is selected in UserComboBox, with the ItemDropDownBox_3 being a choice - if something is selected in this as well it filters the gallery for User X and Item Y.

 

Alternatively, the user can just select an Item from ItemDropDownBox_3, and this will show ALL users with Item X.

 

For information on the app, it's a stock taking app, where users can "order" an item or items, some items are Loaned items and others are Issued, we care more about Loaned items than issued, but issued need accounting for in terms of how much stock we have remaining.

 

Does this make more sense, and is it possible or am I complicating things? 😂

StalinPonnusamy
Community Champion
Community Champion

Hi @Izzet7 

 

With(
    {wCode: UsersItemRequest},
    Sort(
        Filter(
            wCode,
            (IsBlank(UserComboBox.SelectedItems) || IsEmpty(UserComboBox.SelectedItems) || UserComboBox.Selected.DisplayName in Title) 
&& (Toggle1_1.Value = false || IsLoanItem = Toggle1_1.Value) 
&& (IsBlank(ItemDropdownBox_3.Selected) || Item = ItemDropdownBox_3.Selected.Value)
        ),
        Title,
        Ascending
    )
)

 

To test this filter, add filter one by one and we can see the difference.

 

Sample

StalinPonnusamy_0-1634329905363.png

 

 

 

 

 

View solution in original post

Absolute legend. Thank you so much @StalinPonnusamy!

StalinPonnusamy
Community Champion
Community Champion

Thank you. I'm glad that able to help you. Thanks for the explanation.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,517)