Skip to main content

Notifications

How to - Sort on Blank Columns

There are 2 simple ways to sort a gallery to display blank fields all at the top or all at the bottom , however they are not what you might think. Sort requires text or numerical values to sort on and doesn't sort on the blank column.

Both methods use the AddColumns function. In the added column one of 2 numbers is assigned. You can use any two numbers you like. In the examples below, 0 is being assigned for items if the column has a value and 9999 if it is blank.

1. This method creates a new collection that includes a new column. The collection can be created in the App OnStart or the start screen OnVisible properties or in the OnSelect or OnChange property of a control such as a button, dropdown or combobox. In the Gallery you will use the new collection and sort on the newly added column.

 

 

ClearCollect(colNewCollectionName, AddColumns(DataSourceName, "NewColumnName", If(!IsBlank(ExistingColumnName), 0, 9999))

 

 

2. Use this method if you are accessing your data source directly in the items property of the gallery.

 

 

Sort(AddColumns(DataSourceName, "NewColumnName", If(!IsBlank(ExistingColumnName), 0, 9999), NewColumnName, Ascending)

 

 

You can also use the SortByColumns function if you need more precise sorting.

Comments

*This post is locked for comments