cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Jmerk
Level: Powered On

Sort galley by calculated field in galley

I am displaying a galley which is based on one sharepoint list.  In my galley, I have a label where I am displaying the number of connected ID numbers in another sharepoint list using 

 

CountIf(StrikeRecords, StudentID=ThisItem.StudentID)

 

My question is there a way that I can sort my galley based on the value of this label in my gallery?  Currently I am sorting by name.

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Sort galley by calculated field in galley

@Jmerk 

My 1st suggestion is to use this code to count rows instead.  It will count up to 2000 matching records.  Your code will only look at the first 500 rows in the datasource and the count will be 500 or less.

 

CountRows(Filter(StrikeRecords, StudentID=ThisItem.StudentID))

 

My 2nd suggestion is instead of sorting by the label you should create a new collection and add the CountRows as a new column.  Replace my placeholder names with your datasource and column names.

 

ClearCollect(
    yourCollectionName,
    ForAll(
        your_datasource_name,
        {
            field1: field1,
field2: field2,
field3: field3, Count: CountRows(Filter(StrikeRecords, StudentID=ThisItem.StudentID)) } ) )

Then use this code in the Items property of your gallery.

 

Sort(yourCollectionName,Count,Descending)

 

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

View solution in original post

2 REPLIES 2
Super User
Super User

Re: Sort galley by calculated field in galley

@Jmerk 

My 1st suggestion is to use this code to count rows instead.  It will count up to 2000 matching records.  Your code will only look at the first 500 rows in the datasource and the count will be 500 or less.

 

CountRows(Filter(StrikeRecords, StudentID=ThisItem.StudentID))

 

My 2nd suggestion is instead of sorting by the label you should create a new collection and add the CountRows as a new column.  Replace my placeholder names with your datasource and column names.

 

ClearCollect(
    yourCollectionName,
    ForAll(
        your_datasource_name,
        {
            field1: field1,
field2: field2,
field3: field3, Count: CountRows(Filter(StrikeRecords, StudentID=ThisItem.StudentID)) } ) )

Then use this code in the Items property of your gallery.

 

Sort(yourCollectionName,Count,Descending)

 

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

View solution in original post

Jmerk
Level: Powered On

Re: Sort galley by calculated field in galley

I did a workaround for this by first patching my sharepoint list and then adding the new field to my galley.  I like your solutions as well, but for my situation, i can use this number is other connected apps.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (5,799)