cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

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
Highlighted
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
Highlighted
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

Highlighted
Frequent Visitor

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
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (6,985)