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

Get Fabric Certified for FREE during AI Skills Fest. This week only. Secure your voucher now.

Reply
Gpensabene
Frequent Visitor

Complex Cumulative (Running) Totals on filtered Table

Hi expert,

I will try to share the complex scenario with the following example.

 

The Cumulative sum doesn't work with my scenario, or rather, the calculation is correct but it is not what I want.

The problem is that in the original table the comparison field is always the same (QTY = 1), but the summarization depends on the applied filters.

 

Table

2020-04-23_11-16-25.jpg

 

 Example2020-04-23_11-16-25.jpg

Expected values

NC_CODEQTYRunning Total MEASUREExpected Values
SCANNERTYPE1351187135
CALBUTTON1291187264
LIN15KG991187363
LCTYPE961187459
SENTRYFNL771187536
TESTPORT771187613
CALIBRATION571187670
ERASEEMMC461187716
POWERUP461187762
LIN2_5KGD431187805
ECCENTRICITY_RR411187846
READLABEL381187884
LIN1KG361187920
LOADAPP321187952
LOADWAVES251187977
INSTRUCTIONS2411871001
LIN2_5KG1911871020
LOADTOPMN1811871038
LOADCFG1611871054
SENTRYRNL1411871068
TPORTOFF1311871081
CURRENT1111871092
ECCENTRICITY_RF1111871103
SCALE1011871113
SETHWID911871122
EXERCISE611871128
LIN1KGD611871134
SELFTESTMAN611871140
SETIF611871146
LIN10KG511871151
LIN6KG511871156
MAXKG411871160
ENGAGE311871163
LCCHKSUM311871166
LIN15KGD311871169
SENTRYRFL311871172
SOME RANDOM311871175
ZEROACCURACY311871178
ECCENTRICITY_LR211871180
LIN10KGD211871182
COUNTMODE0111871183
ECCENTRICITY_LF111871184
LCSPSWID111871185
LIN6KGD111871186
SET_IF111871187

 

Here you can find the link to the file

Complex Cumulative.pbix 

 

Any help would be greatly appreciated.

 

Regards

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @Gpensabene ,

 

Create a measure for the total quantity and use that measure as your value in the filter so you will need this two measures:

 

TotalQTY = SUM ('Table'[QTY])



Running Total MEASURE__ =
IF (
    NOT ( ISBLANK ( [TotalQTY] ) );
    CALCULATE (
        [TotalQTY];
        FILTER ( ALL ( 'Table'[NC_CODE] ); SUM ( 'Table'[QTY] ) <= [TotalQTY] )
    )
)

 

Now if you add to your model you get the result below:

 

runningtotal.png

 

Check PBIX file attach.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português





View solution in original post

2 REPLIES 2
v-xuding-msft
Community Support
Community Support

Hi @Gpensabene ,

I have tested the pbix file that MFelix did. It works perfectly. If it works for you, please accept the helpful answer as a solution. If you still have questions, please feel free to ask us.

 
Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
MFelix
Super User
Super User

Hi @Gpensabene ,

 

Create a measure for the total quantity and use that measure as your value in the filter so you will need this two measures:

 

TotalQTY = SUM ('Table'[QTY])



Running Total MEASURE__ =
IF (
    NOT ( ISBLANK ( [TotalQTY] ) );
    CALCULATE (
        [TotalQTY];
        FILTER ( ALL ( 'Table'[NC_CODE] ); SUM ( 'Table'[QTY] ) <= [TotalQTY] )
    )
)

 

Now if you add to your model you get the result below:

 

runningtotal.png

 

Check PBIX file attach.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português





Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.