Power Community

Power Community

How to – Sort on Blank Columns

image

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.

This post was originally published on this site

- Advertisement -spot_img

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement - Advertisement

Latest News

New in Spring 2024: Map Routing and Visualization for Power Pages Portals

“Morning Jo, what is the Tea this morning?”, Josh asked as he rushed into the office. “Well, Maplytics is...

More Articles Like This

- Advertisement -spot_img