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

Filter gallery with DropDown

Hi guys, @mdevaney 

 

I need to be able to filter my gallery with the dropdown I have... The dropdown is on the same screen that the Gallery.

 

Gallery code: 

 

Sort(AddColumns(Filter([@'Stock Management'],StartsWith(Title,TextSearchBox1.Text)),"SortRank",(Stock/Threshold)),SortRank,If(SortDescending1,Descending,Ascending))

 

 

Dropdown code:

 

colDropdownOptions

 

 

Variable colDropdownOptions is from the screen Onvisible property:

 

ClearCollect(colDropdownOptions, {Result: "All"});
Collect(colDropdownOptions, Distinct('Stock Management',Description))

 

 

 

I've attached the dropdown screenshot... 

 

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions

I am guessing it is the If statement. Try this instead:

Sort(
    AddColumns(
        Filter(
            'Stock Management',
            StartsWith(
                Title,
                TextSearchBox1.Text
            ),
            Description = Dropdown.Selected.Result || Dropdown.Selected.Result = "All"
        ),
        "SortRank",
        (Stock/Threshold)
    ),
    SortRank,
    If(
        SortDescending1,
        Descending,
        Ascending
    )
)

This may do the trick and not give any issues with the added column. Let me know!

View solution in original post

8 REPLIES 8
Resident Rockstar
Resident Rockstar

Hey @AnthonyRegnier, try this out:

Sort(
    AddColumns(
        Filter(
            [@'Stock Management'],
            StartsWith(
                Title,
                TextSearchBox1.Text
            ),
            If(
                Dropdown.Selected.Result = "All",
                true,
                Description = Dropdown.Selected.Result
            )
        ),
        "SortRank",
        (Stock/Threshold)
    ),
    SortRank,
    If(
        SortDescending1,
        Descending,
        Ascending
    )
)

Please note I used the name "Dropdown" for the dropdown, so you will want to replace that with the actual name. Let me know if that doesn't work out for you; I'd be happy to follow up if needed!

Wow that works straight away oh my gosh! You guys are champs.

 

I just get the common warning saying that it might not work on large data set - anything we can do about it?

 

Thanks!!!

 

Anthony

What data source are you using? SharePoint? If so, I think all the filters should delegate. It could be the @ symbol on the data source name. Maybe try this:

Sort(
    AddColumns(
        Filter(
            'Stock Management',
            StartsWith(
                Title,
                TextSearchBox1.Text
            ),
            If(
                Dropdown.Selected.Result = "All",
                true,
                Description = Dropdown.Selected.Result
            )
        ),
        "SortRank",
        (Stock/Threshold)
    ),
    SortRank,
    If(
        SortDescending1,
        Descending,
        Ascending
    )
)

It could also be the added column, SortRank. If that is the case, you could try adding a calculated column to your table that will produce the same result but will also delegate. To test that out, try this and see if it still has the delegation warning:

// I commented out all the code related to SortRank
// Sort(
    AddColumns(
        Filter(
            'Stock Management',
            StartsWith(
                Title,
                TextSearchBox1.Text
            ),
            If(
                Dropdown.Selected.Result = "All",
                true,
                Description = Dropdown.Selected.Result
            )
        ),
        "SortRank",
        (Stock/Threshold)
/*    ),
    SortRank,
    If(
        SortDescending1,
        Descending,
        Ascending
    ) */
)

Let me know if that works (or doesn't)!

Hey @wyotim 

 

Please check the screenshot attached, it shows the underline code producing the warning.

It says "Delegation warning, the filter part of this formula might not work on large data set".

 

I am using SharePoint indeed.

 

Any possibility to avoid creating a new column?

 

Thanks a lot

Anthony

 

 

I am guessing it is the If statement. Try this instead:

Sort(
    AddColumns(
        Filter(
            'Stock Management',
            StartsWith(
                Title,
                TextSearchBox1.Text
            ),
            Description = Dropdown.Selected.Result || Dropdown.Selected.Result = "All"
        ),
        "SortRank",
        (Stock/Threshold)
    ),
    SortRank,
    If(
        SortDescending1,
        Descending,
        Ascending
    )
)

This may do the trick and not give any issues with the added column. Let me know!

View solution in original post

It works like a charm. 

Super cool man, thanks a ton! Big kudos!

Happy I was able to help out! Feel free to @ me in the future if any other issues come up!

@wyotim  be ready then because I have some more topics 🙂

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (89,115)