Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

How to calculate the sum of one column based on the running total of another column?

Using the example below, how would I calculate the dollar amount for the first forty cases that were sold?

 

What would the formula be to calculate the dollar amount for a running total of the "# of Cases" column?

 

Example:

 

$ Amount   # of Cases

$100                 5

$150               20

$60                 15

$75                 10

$90                 13

$120               15

$40                   8

 

1 ACCEPTED SOLUTION
v-deddai1-msft
Community Support
Community Support

Hi @Anonymous ,

 

You need to create an index column in query editor , then you can create the following two columns:

Running total cases = CALCULATE(SUM('Table'[# of cases]),FILTER('Table','Table'[Index]<=EARLIER('Table'[Index])))

Runnning total amount = CALCULATE(SUM('Table'[Amount]),FILTER('Table','Table'[Index]<=EARLIER('Table'[Index])))

Capture1.PNG

Use Running total cases as slicer:

 

Capture2.PNG

 

For more details, please refer to the pbix file: https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/Ee_C4EXmY11HgazNTBQ434wB4j4f0qWBp3kVoXpZzCq1bQ?e=6AbZm7

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Dedmon Dai

 

View solution in original post

2 REPLIES 2
v-deddai1-msft
Community Support
Community Support

Hi @Anonymous ,

 

You need to create an index column in query editor , then you can create the following two columns:

Running total cases = CALCULATE(SUM('Table'[# of cases]),FILTER('Table','Table'[Index]<=EARLIER('Table'[Index])))

Runnning total amount = CALCULATE(SUM('Table'[Amount]),FILTER('Table','Table'[Index]<=EARLIER('Table'[Index])))

Capture1.PNG

Use Running total cases as slicer:

 

Capture2.PNG

 

For more details, please refer to the pbix file: https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/Ee_C4EXmY11HgazNTBQ434wB4j4f0qWBp3kVoXpZzCq1bQ?e=6AbZm7

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Dedmon Dai

 

darentengmfs
Post Prodigy
Post Prodigy

Hi @Anonymous 

 

You can do so by first creating a running total of # of Cases (if you have date or ID column).

 

Then, create a measure that sums $ amount, put that in a chart, and use the running total column as a filter, where running total <= 40.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.