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.
Solved! Go to Solution.
@Anonymous
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."
@Anonymous
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."
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.
Hi Mdevaney,
Thanks for your suggestions, and I try to solve my problem the same as above. However, I try to use suggestion 2, but I can't get the ThisItem. I feel confused about where I should write the code. Could you help me? I look forward to your reply.
Best,
Qianting
User | Count |
---|---|
247 | |
105 | |
82 | |
50 | |
43 |