cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Martin_W
Helper II
Helper II

Newbie Questions! Sorting a datatable

Hello.

 

I've created a Sharepoint list, with "normal" fields like Client Name, Order value, etc.

 

When I try to sort that data table, for some reason, if I use SortByColumns none of the fields I created appear in the intellisense dropdown (that is, the dropdown that suggests fields to put into formulae at design time) but if I use Sort those fields DO show. Why is this?

 

Also, I have found a youtube video showing runtime sorting of data tables using an assigned variable, and then nested If statements to go into the data table "Items" field. This seems a really clunky way of doing it. Surely there's an event driven method of doing this without variables? I mean, what would make sense is if there was a command to change the sort order of a table that you could put into a button? For example, if the SortByColumns or Sort commands were in the button's "OnSelect" field, that would make sense to me. Am I missing something?

 

thanks,

 

Martin

1 REPLY 1
Drrickryp
Super User
Super User

@Martin_W 

Since your column names include spaces, this will produce a difference between the syntax for Sort() and SortByColumns().  To refer to the column name in a Sort(), 'Column Name' will work,

for a SortByColumns, "Column_x0020_Type" is the proper syntax.  Note the difference in single and double quotes and the need for _x0020_ to account for the space.  In the future, when you name your columns, use CamelCase instead of spaces and avoid unusual characters.   See #4 in https://powerusers.microsoft.com/t5/Power-Apps-Community-Blog/The-Ten-Commandments-of-SharePoint-in-... 

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events that are happening this month - don't miss out!

Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (4,284)