cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JR-BejeweledOne
Super User
Super User

Use Item from Multi-Select combobox to filter gallery

This is a bit different than most questions surrounding this.

 

I am creating a comparison that will consist of a combobox and 4 galleries.  The galleries visibility will be controlled by how many items are selected in the Combobox.

 

What I need to do now is to set each gallery to be filtered by the matching selection in the combobox.

 

Gallery1 would be selected by the first item in the box

Gallery2 would be selected by the 2nd item in the box and so on.

 

I don't know if I need to use ungroup, with, as or a combination of these to extract the correct item to use for filtering each gallery.

 

Any help will be appreciated.

 

@RandyHayes 



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.
1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@JR-BejeweledOne 

So then for the Visible property of each Gallery:

Gallery1 -  CountRows(yourCombobox.SelectedItems)>0

Gallery2 -  CountRows(yourCombobox.SelectedItems)>1

Gallery3 -  CountRows(yourCombobox.SelectedItems)>2

Gallery4 -  CountRows(yourCombobox.SelectedItems)>3

 

Items property of Galleries:

Gallery1:

 

With({_sel: Last(FirstN(yourCombobox.SelectedItems, 1)},
    Sort(
        Filter(Holidays, 
            Country = _sel.Country &&
            Region = _sel.Region
        ),
        Date
    )
)

 

 

Gallery2:

 

 

With({_sel: Last(FirstN(yourCombobox.SelectedItems, 2)},
    Sort(
        Filter(Holidays, 
            Country = _sel.Country &&
            Region = _sel.Region
        ),
        Date
    )
)

 

 

 

Gallery3:

 

 

With({_sel: Last(FirstN(yourCombobox.SelectedItems, 3)},
    Sort(
        Filter(Holidays, 
            Country = _sel.Country &&
            Region = _sel.Region
        ),
        Date
    )
)

 

 

 

Gallery4:

 

 

With({_sel: Last(FirstN(yourCombobox.SelectedItems, 4)},
    Sort(
        Filter(Holidays, 
            Country = _sel.Country &&
            Region = _sel.Region
        ),
        Date
    )
)

 

 

 

 

Now, the above is a lot of duplication and the reality is you can really have all the information in the Combobox

 

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

7 REPLIES 7
RandyHayes
Super User
Super User

@JR-BejeweledOne 

I need a little clarity on the scenario.

Can you provide the Items property for the Combobox and explain a little about these phrases : "Gallery1 would be selected by the first item in the box"?

Are you referring to a visible property or something to do with the Items of the Gallery or actually selecting the Gallery items?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
JR-BejeweledOne
Super User
Super User

I am trying to setup a compare.  These are Holiday lists for different countries or country/regions.   The thought is that someone could select up to 4 different locations from the list of locations in a combobox. 

 

Each one of the selected locations would be the filter for 1 of the 4 galleries.   There are 2 additional screens in the app that show the holidays in different ways.  To give you an idea, here is one of the screens.

 

holidaymonthview.png

 

 

The goal for the last screen is to show the holidays for the selected locations the same you see in the gallery on the right.

 

The formula for that gallery:

 

 

If(
    !IsBlank(DropdownRegion2), Sort(Filter(Holidays, Country = DropdownCountry2.Selected.Result && Region = DropdownRegion2.Selected.Result), Date, Ascending),
    Sort(Filter(Holidays, Country = DropdownCountry2.Selected.Result), Date, Ascending)
)

 

 

 

The combobox is multi-select showing 2 fields and the formula is:

 

 

GroupBy(HolidaysIndividual,
        "Country", "Region", "Result"
)

 

 

So if my ComboBox selection looks like this, where #1 is the country and #2 is the region.   I want to filter gallery1 by Australia, New South Wales (NSW), Gallery2 by Australia, Queensland (QLD), Gallery3 by Australia, South Australia (SA) and Gallery4 by Australia, Victoria (VIC), with the understanding that it could be any item selected from the list.

 

comboboxselect.png

 



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.
RandyHayes
Super User
Super User

@JR-BejeweledOne 

Thanks for the detailed information.

So one thing - are you limiting to 4 selections?  You mention 4 galleries...so what if there are 5 selections or 3?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

I am limiting to 4.

 

There will be Count values to compare for visibility of the galleries and could be used for the items property as well in galleries 2 - 4.



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.
RandyHayes
Super User
Super User

@JR-BejeweledOne 

So then for the Visible property of each Gallery:

Gallery1 -  CountRows(yourCombobox.SelectedItems)>0

Gallery2 -  CountRows(yourCombobox.SelectedItems)>1

Gallery3 -  CountRows(yourCombobox.SelectedItems)>2

Gallery4 -  CountRows(yourCombobox.SelectedItems)>3

 

Items property of Galleries:

Gallery1:

 

With({_sel: Last(FirstN(yourCombobox.SelectedItems, 1)},
    Sort(
        Filter(Holidays, 
            Country = _sel.Country &&
            Region = _sel.Region
        ),
        Date
    )
)

 

 

Gallery2:

 

 

With({_sel: Last(FirstN(yourCombobox.SelectedItems, 2)},
    Sort(
        Filter(Holidays, 
            Country = _sel.Country &&
            Region = _sel.Region
        ),
        Date
    )
)

 

 

 

Gallery3:

 

 

With({_sel: Last(FirstN(yourCombobox.SelectedItems, 3)},
    Sort(
        Filter(Holidays, 
            Country = _sel.Country &&
            Region = _sel.Region
        ),
        Date
    )
)

 

 

 

Gallery4:

 

 

With({_sel: Last(FirstN(yourCombobox.SelectedItems, 4)},
    Sort(
        Filter(Holidays, 
            Country = _sel.Country &&
            Region = _sel.Region
        ),
        Date
    )
)

 

 

 

 

Now, the above is a lot of duplication and the reality is you can really have all the information in the Combobox

 

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

I don't see any difference in the very last formula from the ones above that you say are duplication.



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.
RandyHayes
Super User
Super User

@JR-BejeweledOne 

Actually, that very last part with the header of Gallery3 is all to be ignored.  I believe I copy/pasted one too many times and didn't notice that part below my last sentence about the duplication and combobox when I hit reply.

I've removed it out of the post.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

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 (1,643)