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

Notifications

Announcements

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 most listed item

(0) ShareShare
ReportReport
Posted on by 117

Hi guys,

 

I have 3 tables, first one with different instruments, second one with different 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.

Now I want to sort the gallery "topInstruments" by the most listed instruments - instruments used multiple times in sets should be displayed first in the gallery, the ones used only once should be displayed at the bottom of the gallery.

 

Does anybody know how the sort should look like?

 

Thanks

Categories:
I have the same question (0)
  • Verified answer
    mdevaney Profile Picture
    29,989 Moderator on at

    @katunar
    I would use this code in the Items property of your Gallery.  Better instructions could be given if you supply a sample of each data table

     

    Sort(
     ForAll(
     your_instruments_datasource, 
     {
     Instrument: instrument_field_name,
     InstrumentCount: CountRows(Filter(your_m2m_datasource, InstrumentID = your_instrument_datasource[@InstrumentID])
     }),
     InstrumentCount
    )



    —-
    Please Accept as Solution if this post answered your question so others may find it more quickly. If you found this post helpful consider giving it a Thumbs Up.

  • cds Profile Picture
    1,001 on at

    Congrats on most kudoed @mdevaney!

     

    This is my first time seeing this syntax in powerapps. Nice!

  • mdevaney Profile Picture
    29,989 Moderator on at

    Thank you for the congratulations @cds, your are very kind! Cat Happy

     

    I've been noticing your posts here recently and I think they are very helpful.  Keep up the good work!

  • katunar Profile Picture
    117 on at

    Thanks @mdevaney. Last thing to mention is that I had to add descending at the end. Everything else works fine. Thank you!

  • katunar Profile Picture
    117 on at

    Hi @mdevaney , I've got another problem to solve.

    I now additionally have the column "amount" in my many-to-many table. So now it is not just based on how many sets contain the instrument, but also how many times the instrument is in the set. so basically I want to know the total amount of the instruments in sets - 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 a total amount of 6, Instrument_C second with amount of 4 and Instrument_B third with amount of 2.

     

    You think you can solve this?

     

    Thank you very 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard