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 / Sort gallery by calcul...
Power Apps
Answered

Sort gallery by calculated Label text

(0) ShareShare
ReportReport
Posted on by

Hi,

I'm pretty new to Power Apps and having a problem I can't quite solve with the resources I found online, especially in this forum.

I've created a Gallery inside a Container, that Gallery works on an Entity as its data source (I hope I'm using the right vocabulary), the "Items" code is: "Filter(Entity; 'Entity (Views)'.'View'). I've translated this from German.

 

I've then added another Label to the Gallery that is used to calculate and display something using data from another entity:

Sum(Filter(Entity_2; Entity_2_Column1.Name = ThisItem.Name; DateDiff(Entity_2_Column2;Today();Days)<=7);Entity_2_Column3)

Entity_2_Column1 is a lookup column pointing to the Entity the Gallery uses as data source.

 

I would now like to sort the Gallery by the calculated values displayed in the Label's Text. How can I do that?

 

Thank you!

Categories:
I have the same question (0)
  • LuizVicente Profile Picture
    984 Super User 2024 Season 1 on at

    Did you manage to resolve this issue?
    If not, share a little bit of how your data is structured so I can better elaborate on a way to do this.

  • Verified answer
    v-jefferni Profile Picture
    Microsoft Employee on at

    Hi @dev12753 ,

     

    Sorting in a Gallery is actually sorting on the Items of this Gallery. In your case, you will need to add the values to an additional column. So, you need an AddColumns function to help achieve this:

    Sort(
     AddColumns(
     Filter(Entity; 'Entity (Views)'.'View'); 
     "SumDays";
     Sum(Filter(Entity_2; Entity_2_Column1.Name = ThisItem.Name; DateDiff(Entity_2_Column2;Today();Days)<=7);Entity_2_Column3)
     );
     SumDays;
     Ascending
    )

     

    However, you should be noted that this formula is not delegable so it will not work for a large data set. 

     

    Best regards,

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 530

#2
WarrenBelz Profile Picture

WarrenBelz 459 Most Valuable Professional

#3
Haque Profile Picture

Haque 314

Last 30 days Overall leaderboard