cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tnw
Regular Visitor

Sorting gallery by boolean value

I'd like to sort my gallery by boolean value, which is possible, but I'd like false/null values to appear first. Currently the sort function results in true values appearing first regardless of ascending or descending sort order.

 

Does anyone know how to get false/null values to appear first instead?

1 ACCEPTED SOLUTION

Accepted Solutions

I'd suggest creating a new column that groups everything into true or false then sort that. 

 

SortByColumn(AddColumn( DataSource, ColumnName, if(blah.text = true, true,false)),ColumnName,Ascending)

 

It'd look something like this

View solution in original post

5 REPLIES 5
Krishna92
Microsoft
Microsoft

@tnw 

 

Could you please try using SortByColumns() formula with this you will be able to sort data based on column which will enable you to see the false and null values. 

 

Also could you please try re-configuring the formula once, I also tried using the sort() formula and I was able to see the values 

Please check the reference document for more insights regarding the same.

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-sort

 

If this information helps you with resolution, please consider giving a thumbs up and mark the solution as resolved.

eka24
Super User
Super User

Wrap the formula with sort Example

Sort(Filter( Customers, Column in SortColumn),TrueFalseColumn,Ascending)

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

 

tnw
Regular Visitor

This does sort so that false values appear first but null values appear last. I would like false and null to appear before true values.

I'd suggest creating a new column that groups everything into true or false then sort that. 

 

SortByColumn(AddColumn( DataSource, ColumnName, if(blah.text = true, true,false)),ColumnName,Ascending)

 

It'd look something like this

Use  Addcolumns to create a collection:

ClearCollect(MyTable2,AddColumns(DataSource,"SortColumn",If(TrueFalseColumn="False",1,2)))
 
This makes all false 1 and all others wether true or Null 2
 

Then sort as:

Sort(MyTable2,SortColumn,Ascending)
 
Or
Sort(MyTable2,SortColumn,Descending)
------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (3,972)