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 based on ...
Power Apps
Unanswered

Sort gallery based on the most listed item

(0) ShareShare
ReportReport
Posted on by 117

Hi guys,

 

I have 3 tables, first one with different instruments (instruments), second one with different sets (sets) and the last one with the 2 primary keys (many-to-many). So a set can contain multiple instruments and an instrument can be in multiple sets.

 

Additionally I have the column "amount" in my many-to-many table. So a set can contain a specific instrument multiple times. Basically I want to know the total amount of the instruments in sets and display all the instruments including their amount in a gallery sorted descending by the amount- here is an example:

 

InstrumentID    SetID     Amount

Instrument_A    Set_B     1

Instrument_B    Set_B     2

Instrument_A    Set_A     3

Instrument_C    Set_C     4

Instrument_A    Set_C     2

 

So the Instrument_A should be listed at first with total amount of 6, Instrument_C second with amount of 4 and Instrument_B third with amount of 2.

 

Instrument            Amount

Instrument_A                   6

Instrument_C                   4

Instrument_B                   2

 

Does anyone know how to do it?

 

Thanks

Categories:
I have the same question (0)
  • v-monli-msft Profile Picture
    Microsoft Employee on at

    Hi @katunar ,

     

    I think this cannot be achieved currently. Unless you want to create a new collection and in the formula you need to count for each record manually:

    ClearCollect(C1, {InstrumentID:"Instrument_A",Amount:Sum(Filter(Table3,InstrumentID="Instrument_A"),Amount)}, 
    {InstrumentID:"Instrument_B",Amount:Sum(Filter(Table3,InstrumentID="Instrument_B"),Amount)},
    {InstrumentID:"Instrument_C",Amount:Sum(Filter(Table3,InstrumentID="Instrument_C"),Amount)})

    Then use C1 as the data source of the gallery and sort like this:

    SortByColumns( C1, Amount,Descending )

    Regards,

    Mona

     

    Regards,

    Mona

  • katunar Profile Picture
    117 on at

    Thanks for your reply @v-monli-msft

     

    I think this won't help because it is a dynamic data source in which new records will be created time by time and I can't change the collection everytime a new instrument is patched.

     

    If there is another way, please let me know.

     

    Thanks

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 396 Most Valuable Professional

#2
11manish Profile Picture

11manish 134 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 101 Super User 2026 Season 2

Last 30 days Overall leaderboard