web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Newb help with sort
Power Apps
Answered

Newb help with sort

(0) ShareShare
ReportReport
Posted on by 20

Hi there,

 

I am just starting out woth PowerApps and struggling with a sort command. I have a simple button and a datatable (DailySales) that when the button is clicked it runs a flow. The flow returns data from a sql stored procedure in json with the following values Total sales, Cumulative sales and HourTime. I can get the data back into the table ok but I cannot sort the table by hourtime. I have attempted to do this by using this command on my button:

 

Set(DailySales,PowerAppsbutton.Run()); Sort(DailySales,HourTime,Ascending)

 

I beleive the HourTime comes back as an integer. When I click the button it does not sort the table. 

 

I am also trying to format the table so that the TotalSales column and the Cumulative Sales are in £. Eventually I want to put it in a line graph.

 

I have been reading through the documentation but really struggling so any help would be greatly appreciated.

 

thanks!

 

Paul

 

 

 

Categories:
I have the same question (0)
  • Paulow1978 Profile Picture
    20 on at

    Well for anyone who comes across this issue, I cant figure out why it doesnt work on the button action but I clicked on the DataTable and put the sort in there and it worked. I also figured out how to create new columns and base the results in those columns on the actual columns of data (I put this on the items fx for the DataTable)

     

    AddColumns(DailySales,"Total Sales", Text(TotalSales,"[$-en-US]£ #,###"),"Cumulative Sales", Text(CumulativeSales,"[$-en-US]£ #,###"),"Time", Text(HourTime,"[$-en-US]"))

     

    Then I manually unticked the columns to show so that it only showed the new columns.

     

    The problem I have now is that i cannot add the sort command at the end of the AddCoulns command even putting a ; or ;; at the end. I am trying to get it to look like this:

     

    AddColumns(DailySales,"Total Sales", Text(TotalSales,"[$-en-US]£ #,###"),"Cumulative Sales", Text(CumulativeSales,"[$-en-US]£ #,###"),"Time", Text(HourTime,"[$-en-US]")); Sort(DailySales, HourTime , Ascending)

  • Paulow1978 Profile Picture
    20 on at

    This is really frustrating...

     

    the documentaion on powerapps is awful...

     

    I am now trying to chain a formula for my DataTable and it won't let me. It says its expecting an operator. 

     

    I am trying to do this on my Datatable on the Items FX:

     

    AddColumns(DailySales,"Total Sales", Text(TotalSales,"[$-en-US]£ #,###"),"Cumulative Sales", Text(CumulativeSales,"[$-en-US]£ #,###"),"Time", Text(HourTime,"[$-en-US]"));

    Sort(DailySales, HourTime , Ascending)

     

    If anyone knows why this won't work and they could help me it would be much appreciated!

     

  • Paulow1978 Profile Picture
    20 on at

    I should also say that both forumals work on their own in the items fx just not with a ; put in between them to chain them.

  • Verified answer
    Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    Hi Paulow 

     

    try AddColumns(Sort(DailySales,HourTime,Ascending),"Total Sales", Text(TotalSales,"[$-en-US]£ #,###"),"Cumulative Sales", Text(CumulativeSales,"[$-en-US]£ #,###"),"Time", Text(HourTime,"[$-en-US]"))

     

    powerapps functions execute from inside out, in sequence, hence the above sorts first then adds columns to the sorted datasource. Sometimes, to be more efficient, chained functions are run in parallel. Particularly if the dataset is large, it may be trying to add columns at the same time as it is sorting and it can’t do it. (I have no idea if that’s the case but at least that’s what I imagine is happening). Also, once you add columns to the datasource, it is no longer the same datasource so the sort command on the original datasource, following the addcolumns function wouldn’t make sense.

     

  • Paulow1978 Profile Picture
    20 on at

    You Sir are a genius 🙂

     

    thank you so much!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 414

#2
WarrenBelz Profile Picture

WarrenBelz 377 Most Valuable Professional

#3
Kalathiya Profile Picture

Kalathiya 315 Super User 2026 Season 1

Last 30 days Overall leaderboard