cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dips23
Helper I
Helper I

How to fetch record on specific calculation from the list of records ?

Hello,

 

I have list of records as follows in datasource:

 

Item         Text        Num

Item 1Text 13
Item 2Text 22
Item 2Text 34
Item 1Text 46

 

I want to perform following operations using formula:

 1. Group by Items:

 

Item 1Text 13
Item 1Text 46
   
Item 2Text 22
Item 2Text 34

     

 2. sum Num of grouped item

Item 1Text 13
Item 1Text 46
  sum= 9
Item 2Text 22
Item 2Text 34
  sum=6

 

3. Sort by highest value of  sum of num 

Item        Num Sum

Item 1     9

Item 2     6

 

How can I bind the resulted values as indicated in 3. to list control ? ( Basically, I need distrinct records from the datasource sorted by highest value of thier numbers )

 

I could do group with ClearCollect, but I am stucked at step 2. and 3. - Any suggestions ?

 

Best Regards,

 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@dips23 

You mention "list control".  Are you referring to a Gallery?  Or are you talking about a List box?

If you're looking at a Gallery type control, You can set the Items property of your control to the following:

SortByColumns(
AddColumns(
GroupBy(yourDataSource, "Item", "Items"),
"ItemSum", Sum(Items,Num)),
"ItemSum",Descending)

This will group the records and create a sum of each num within the distinct item.

 

I've attached a sample app with this logic for you to review.

I hope it is helpful for you.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

2 REPLIES 2
RandyHayes
Super User
Super User

@dips23 

You mention "list control".  Are you referring to a Gallery?  Or are you talking about a List box?

If you're looking at a Gallery type control, You can set the Items property of your control to the following:

SortByColumns(
AddColumns(
GroupBy(yourDataSource, "Item", "Items"),
"ItemSum", Sum(Items,Num)),
"ItemSum",Descending)

This will group the records and create a sum of each num within the distinct item.

 

I've attached a sample app with this logic for you to review.

I hope it is helpful for you.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Thank you so much for your time, It did workout for my datasource exactly the way I wanted 🙂 ! You are Awesome!

 

Best Regards,

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (2,540)