cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
Super User
Super User

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

@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. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

2 REPLIES 2
Highlighted
Super User
Super User

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

@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. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

Highlighted
Helper I
Helper I

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

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
Ignite

Microsoft Ignite

This will be a conference that you do not want to miss!

secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (4,665)