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
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (2,469)