Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Gallery filtering wrong with dropdown boxes + collections

(0) ShareShare
ReportReport
Posted on by 158

Hello All, 

 

I have created 2 collections: colPartNumber and colMonth in OnVisible (Screen). I wanted to use them in filter boxes to see option "All". Filters should show option "All" and single distinct record from gallery in dropdown boxes. My gallery's source is excel file. I have no errors on formulas but gallery is filtering wrong.

 

On Dropdown1 where I have collection of all part numbers ("All") and distinct part number I can see correct information so showing me data but does not work on gallery so gallery is not filtering at all - nothing happens when I press part number or "All". 

 

On Dropdown2_4 where I have collection of all months ("All") and distinct month I cannot see anything when press dropdown box only blank lines. I press any blank line and it's working for instance I pressed second blank line and gallery filters through 1st month but for some reason doesn't work with "All" option as it should be the first line. 

 

Code for collections (Screen -> OnVisible):

ClearCollect(colPartNumber, {Result:"All"}, Distinct(Table10, 'PART NUMBER'));
ClearCollect(colMonth, {Result:"All"}, Distinct(Table10, month1));
Collect(colPartNumber, Distinct(Table10, 'PART NUMBER'));
Collect(colMonth, Distinct(Table10, month1))

 

Code for Gallery (Items):

If(
Dropdown1.Selected.Result="All" &&
Dropdown2_4.Selected.Result="All",
Filter(Table10, 'PART NUMBER'=Dropdown1.Selected.Result),
Filter(Table10, month1=Dropdown2_4.Selected.Result)
)

 

Codes for Dropdown boxes (Items):

colPartNumber

colMonth

 

Any ideas anyone, please? 

Thank You!

 

 

Categories:
  • jorge.daniel Profile Picture
    jorge.daniel 1,430 on at
    Re: Gallery filtering wrong with dropdown boxes + collections

    Wow, great 😀

  • MP-13011217-0 Profile Picture
    MP-13011217-0 158 on at
    Re: Gallery filtering wrong with dropdown boxes + collections

    Thank You soo much!!! It's working fine now 🙂 !! just that I need to figure out how to make text on lines visible... 

  • Verified answer
    jorge.daniel Profile Picture
    jorge.daniel 1,430 on at
    Re: Gallery filtering wrong with dropdown boxes + collections

    This should do the trick (replace the names of the controls):

     

    If(
        Dropdown_PartNumber.SelectedText.Value = "All" && Dropdown_Month.SelectedText.Value = "All",
        Table,
        If(
            Dropdown_PartNumber.SelectedText.Value <> "All"  && Dropdown_Month.SelectedText.Value = "All",
            Filter( Table, PartNumber = Dropdown_PartNumber.SelectedText.Value ),
            If(
                Dropdown_PartNumber.SelectedText.Value <> "All"  && Dropdown_Month.SelectedText.Value <> "All",
                Filter( Table, PartNumber = Dropdown_PartNumber.SelectedText.Value && Month = Dropdown_Month.SelectedText.Value ),
                Filter( Table, Month = Dropdown_Month.SelectedText.Value )
            )
        )
    )
  • jorge.daniel Profile Picture
    jorge.daniel 1,430 on at
    Re: Gallery filtering wrong with dropdown boxes + collections

    Replace it with a new one, can you?

  • MP-13011217-0 Profile Picture
    MP-13011217-0 158 on at
    Re: Gallery filtering wrong with dropdown boxes + collections

    Thank You,

     

    It looks like Dropdown1 is working great as it should but Dropdown2_4 works fine only if Dropdown1 is selected to "All". 

    When I choose eg. P611252 and "All" in Dropdown2_4 it shows nothing in gallery. 

    When I choose eg. P611252 and month 1 or 2 or any other it will show me all lines for all months in my gallery (not selected one,... but I don't know exactly what it says as lines are still blank...)

  • MP-13011217-0 Profile Picture
    MP-13011217-0 158 on at
    Re: Gallery filtering wrong with dropdown boxes + collections

    It looks like this and still shows blank lines: 

    marcy_pi_0-1654609011936.png

     

  • jorge.daniel Profile Picture
    jorge.daniel 1,430 on at
    Re: Gallery filtering wrong with dropdown boxes + collections

    As for the Items filtering, you got this

     

    Dropdown1.Selected.Result <>"All",
    Filter(Table10, 'PART NUMBER'=Dropdown1.Selected.'PART NUMBER')

     

    So, anytime you got a month on 1, it will filter your gallery and stop checking any other conditions.

     

    Try this

     


    Dropdown1.Selected.Result <>"All" && Dropdown2_4.Selected.Result<>"All",
    Filter(Table10, 'PART NUMBER'=Dropdown1.Selected.'PART NUMBER')

     

    And you may also have to filter the month there.

  • jorge.daniel Profile Picture
    jorge.daniel 1,430 on at
    Re: Gallery filtering wrong with dropdown boxes + collections

    ok,

     

    Lets break it down to small bites.

     

    For the "white months", plese select the dropdown in your canvas an check the font color and related properties.

    volor.PNG

  • MP-13011217-0 Profile Picture
    MP-13011217-0 158 on at
    Re: Gallery filtering wrong with dropdown boxes + collections

    Thank You! It's working almost ok... 

     

    Dropdown1 - when I choose any option it filters gallery fine. 

    Dropdown2_4 - when I choose any month it's working but only when Dropdown1 in selected on "All". If I pick any other number in Dropdown1 like P611252 and lets say month number 3, it will show me this below (so it won't show me all lines for month 3 but it will show me all lines for month 1 and 2): 

    marcy_pi_0-1654607466015.png

     

    ...also as You can see the values for month are there but not visible... while I have Visibility turned on and the text colour is black on white background. 

     

  • jorge.daniel Profile Picture
    jorge.daniel 1,430 on at
    Re: Gallery filtering wrong with dropdown boxes + collections

    Hi, try Dropdown1.SelectedText instead of Dropdown1.Selected

     

    Also, test these statements in labels, to make sure they return what you expect.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,445

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,741

Leaderboard