cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
christina_hoeg
Advocate I
Advocate I

Combine Filter and sort in PowerApps

Hi,

 

I am hoping someone can help me with a problem I am having:

I have a gallery in PowerApps. The data source is a SharePoint List (OOSListAT). 

Now I want to filter this after a yes/no choice field called "Closed". The comman I used under items for this was the following (and it worked):

Filter(OOSListAT,Closed.Value = "no")

 

Now I also want to add a function to sort the displayed value. The following code I used also worked:

SortByColumns(AddColumns(OOSListAT,"Product2",Product_x0020_Presentation.Value),"Product2",If(SortDescending1,Descending,Ascending))

The column "Product_x0020_Presentation" is a look-up field in the sharpoint list.

 

Now I want to combine those two functions, but I can't seem to get it to work. 

 

Also I would really like to add the function to search the gallery because there will be more than one entry for example for ProductA. So I want the option to enter 'ProductA' in the search bar and get all entries for this product. Is this possible?

 

This is how my app looks at the moment (the search bar doesn't yet work).

FilterAndSort.JPG

Can anyone help me with that?

 

Thank you in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @christina_hoeg ,

Could you please share a bit more about your scenario?

Do you want to filter your Gallery Items based on the "Closed" field and TextSearchbox, and then sort it by a specific column?

 

I have made a test on my side, please consider take a try with the following workaround:

Set the Items property of the Gallery to following:

SortByColumns(
Filter(
AddColumns(OOSListAT, "Product2", Product_x0020_Presentation.Value),
Closed.Value = "no",
StartsWith(Product2, TextSearchBox1.Text)
),
"Product2",
If(SortDescending1,Descending,Ascending)
)

or

SortByColumns(
Filter(
AddColumns(OOSListAT, "Product2", Product_x0020_Presentation.Value),
Closed.Value = "no",
TextSearchBox1.Text in Product2
),
"Product2",
If(SortDescending1,Descending,Ascending)
)

 

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
rebeccas
Super User
Super User

The order to combine those would go like this:

 

SortByColumns(
 Filter(
  Search(
   AddColumns(DataSource,"ColumnName","ColumnSource"),
  input_SearchText.Text, "ColumnSearch1","ColumnsSearch2"),
 ColumnFilter="Description"),
"ColumnSort", If(SortDescending1, Descending,Ascending))

 

v-xida-msft
Community Support
Community Support

Hi @christina_hoeg ,

Could you please share a bit more about your scenario?

Do you want to filter your Gallery Items based on the "Closed" field and TextSearchbox, and then sort it by a specific column?

 

I have made a test on my side, please consider take a try with the following workaround:

Set the Items property of the Gallery to following:

SortByColumns(
Filter(
AddColumns(OOSListAT, "Product2", Product_x0020_Presentation.Value),
Closed.Value = "no",
StartsWith(Product2, TextSearchBox1.Text)
),
"Product2",
If(SortDescending1,Descending,Ascending)
)

or

SortByColumns(
Filter(
AddColumns(OOSListAT, "Product2", Product_x0020_Presentation.Value),
Closed.Value = "no",
TextSearchBox1.Text in Product2
),
"Product2",
If(SortDescending1,Descending,Ascending)
)

 

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

@v-xida-msft  thank you so much for you help! the second option was exactly what I needed!

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Apps Community Call

Monthly Power Apps Community Call

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

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (56,306)