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 / Sorting gallery based ...
Power Apps
Answered

Sorting gallery based on a calculated value

(0) ShareShare
ReportReport
Posted on by 7

Hello all,

I am in need of your help.

I am trying to sort a gallery based on a score that is calculated for each item in the gallery.

It's like a matching process where in List1 i have Title and a lookup column from List2 containing multiple values, also i have a combobox populated with List2's items. So you select wich items from List2  you want to filter the gallery (List1) on and then i have a label in the gallery calculating "Combobox's NumberOfPickedItems / NumberOfMatchedItems in List1's Lookup column. So i want to sort the gallery based on that value.

 

Since it's not a column in the list it's harder to sort it.

I also tried to create a collection with a column containing the calculated value but since the lookup column is a table-value it won't do t for me.

Do you have any ideas?

 

Much appriciated,

deveDennis

Categories:
I have the same question (0)
  • Verified answer
    Community Power Platform Member Profile Picture
    on at

    Hi deveDennis,

     

    I recreated the two lists you described in your post (very simply) to work as shown below:


    LookupDemo1.png

     

    In PowerApps I have added ComboBox control and a Gallery. The ComboBox is set to display the Title column of List2. This ComboBox is set to allow multiple selections and to the OnChange property I have added the following formula:

     

     

    ClearCollect(
     GalleryItems,
     AddColumns(
     List1,
     "NumberOfMatches",
     CountRows(
     Filter(
     LookUpColumn,
     Value in ComboBox1.SelectedItems.Title
     )
     )
     )
    )

     

    This creates a new collection that contains List1 along with a new column that is the count of how many values in each of List1's lookup column appear in the values selected in the ComboBox.

     

    I have then set the items property of the Gallery to be the new GalleryItems collection sorted by the "NumberOfMatches" columns with the following formula:

     

    SortByColumns(GalleryItems,"NumberOfMatches",Descending)

    This results in the 10 rows of List1 being sorted by the number of matches they have in the selected items.LookupDemo2.png

     

    With this value calculated you can probably do some funky maths to work out the percentage match etc.

     

    Hope this helps, it was fun to figure out Robot Happy

     

     

  • deveDennis Profile Picture
    7 on at

    Hey JimmyBecks,

     

    This is exactly what I needed, works perfectly!

    Nice job and thanks alot! 🙂

    /Dennis

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 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard