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

Gallery filtering wrong with dropdown boxes + collections

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!

 

 

17 REPLIES 17
jcfDaniel
Super User
Super User

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


Regards. JD.
jcfDaniel
Super User
Super User

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.


Regards. JD.

It looks like this and still shows blank lines: 

marcy_pi_0-1654609011936.png

 

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...)

Replace it with a new one, can you?


Regards. JD.
jcfDaniel
Super User
Super User

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 )
        )
    )
)

Regards. JD.
marcy_pi
Helper III
Helper III

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

jcfDaniel
Super User
Super User

Wow, great 😀


Regards. JD.

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Check out the New Ideas Site

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (4,527)