cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TomWright
Level: Powered On

Help with Gallery Filtering

I have the below code:

SortByColumns(Search('To Do List', TextSearchBox1.Text, "Title"), "ID", If(SortDescending1, Descending, Ascending))

 

I need the gallery not to display results from the sharepoint data sorce that comply with the status "Completed" Ive read a few other posts but struggling to mix the code in with mine. Tom

1 ACCEPTED SOLUTION

Accepted Solutions
Power Apps Staff CarlosFigueira
Power Apps Staff

Re: Help with Gallery Filtering

Ah, if your sharepoint column is named "Status", and (it seems to be) of type choice, then the expression should reference that column name, something along the lines of 

SortByColumns(
    Search(
        Filter('To Do List', Status.Value <> "Completed"),
        TextSearchBox1.Text,
        "Title"),
    "ID",
    If(SortDescending1, Descending, Ascending))

View solution in original post

5 REPLIES 5
Power Apps Staff CarlosFigueira
Power Apps Staff

Re: Help with Gallery Filtering

You would use the Filter function in this scenario:

SortByColumns(
    Filter(
        Search('To Do List', TextSearchBox1.Text, "Title"),
        Completed = false),
    "ID",
    If(SortDescending1, Descending, Ascending))

Expressions in PowerApps can be nested, so in the example above you're filtering the result of the Search operation based on the condition that you want.

TomWright
Level: Powered On

Re: Help with Gallery Filtering

Hi Carlos,

 

Is it possible to only show items in the gallery were completed is false, before the search is run

Power Apps Staff CarlosFigueira
Power Apps Staff

Re: Help with Gallery Filtering

Sure, both Search and Filter functions "filter" the rows that are returned by the data source, without changing its "shape", so their order can be flipped, and the results should be the same:

SortByColumns(
    Search(
        Filter('To Do List', Completed = false),
        TextSearchBox1.Text,
        "Title"),
    "ID",
    If(SortDescending1, Descending, Ascending))
TomWright
Level: Powered On

Re: Help with Gallery Filtering

Thanks, altough how does it know what colum to look in for the "Completed status"? This is the sharepoint formIMG2.JPG

No results are being retunred?

IMG1.JPG

 

Thank you for your help, its much appreciated

Power Apps Staff CarlosFigueira
Power Apps Staff

Re: Help with Gallery Filtering

Ah, if your sharepoint column is named "Status", and (it seems to be) of type choice, then the expression should reference that column name, something along the lines of 

SortByColumns(
    Search(
        Filter('To Do List', Status.Value <> "Completed"),
        TextSearchBox1.Text,
        "Title"),
    "ID",
    If(SortDescending1, Descending, Ascending))

View solution in original post

Helpful resources

Announcements
New Ranks and Rank Icons in April

'New Ranks and Rank Icons in April

Read the announcement for more information!

Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (8,892)