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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
llavey
Regular Visitor

Cumulative Total DAX

Row LabelsSum of Ext QtyCumulative Extr Qty FailsSum of DELIVERY_QTY_EXPExtr DPMCumulative Extr DPM
2015-11224223.7605022222,282,7871.01.0
2015-12315539.1262961174,694,9471.81.4
2016-01262801.1768099177,758,6551.51.4
2016-02103903.8266581211,934,8930.51.1
2016-033906.8266581197,277,2940.00.9
2016-045911.3928682197,876,4620.00.8
2016-0500158,747,5080.00.0
Grand Total911911.39286821,340,572,5460.70.7

When the Sum of Ext Qty = 0, then i want the Cumulative Extr Qty Fails to add that 0 and always show a Cumulative total.  But it doesn't, it just shows 0.  How do i modify my formula to always show running total, even if Sum of Ext Qty = 0?

 

My DAX formula:

Cumulative Extr Qty Fails:=calculate(if(sum('A'[Extrapolated Qty])=BLANK(),0,sum ('A'[Extrapolated Qty])),FILTER(ALLSELECTED ('A'),A[Year-Month]<=MAX ('A'[Year-Month])))

11 REPLIES 11
Sean
Community Champion
Community Champion


 How do i modify my formula to always show running total, even if Sum of Ext Qty = 0?

 

My DAX formula:

Cumulative Extr Qty Fails:=calculate(if(sum('A'[Extrapolated Qty])=BLANK(),0,sum ('A'[Extrapolated Qty])),FILTER(ALLSELECTED ('A'),A[Year-Month]<=MAX ('A'[Year-Month])))


 @llavey I believe i answered your original Question...

 

And no I did not create any new columns.

All I did was change the MEASURE formula....

Cumulative Total2.png

Sean
Community Champion
Community Champion

@llavey Is this a trick question?

 

Get rid of the condition...

Cumulative Extr Qty Fails :=
CALCULATE (
    SUM ( 'A'[Extrapolated Qty] ),
    FILTER ( ALLSELECTED ( 'A' ), A[Year-Month] <= MAX ( 'A'[Year-Month] ) )
)
llavey
Regular Visitor

Why would i get rid of this?  I need it for the Cumulative DPM for each month?

Sean
Community Champion
Community Champion

@llavey Not sure what you mean?

 

Cumulative Total.png

llavey
Regular Visitor

So, you've added another Cumulative Ext Qty Fails column to the pivot and made it a running total, which works great.  The problem is I have a Cumulative Ext DPM column which will take the Cumulative Ext Qty Fails/Cumulative Exp Shipments*1000000 for each month.  Any idea how to accomodate that if I get rid it?

 

Right now, i have another DAX formula for the Cumulative DPM that uses the Cumulative Extr Qty Fails:

Cumulative Extr DPM:=([Cumulative Extr Qty Fails]/[Cumulative Exp Shipments])*1000000

 

Maybe i'm making this way harder than it should be.

Sean
Community Champion
Community Champion

As far as this new question...

 

What is Cumulative Exp Shimpments? It was not included in the sample data?

llavey
Regular Visitor

Ah, i see what you did.  However, I want the value for 2016-05 Cumulative Extr Qty Fails (highlighted in yellow) to be 911.392 and not 0.

 

 

This is my only question.  Sorry for confusion.

 

 Capture.JPG

Sean
Community Champion
Community Champion

All I really did was just modify the Measure which sums the values in [Sum of Ext Qty] column - nothing else

 

That zero is from the sample data you posted - I included it in the Matrix just to compare - I have not created any columns

 

Cumulative Total2.png

 

llavey
Regular Visitor

The original table i posted was a copy of the pivot table in Excel Services.  The raw data in Visual Studio looks like this:

 

Lot IDCURRENT_QTYExtrapolated Qty
CQMHY82.11116
CQG7Y82.11116
CQ43172.11116
CQF3172.11116
CQN4172.11116

My DAX formulas are:

 

Sum of CURRENT_QTY:=if(SUM('DRAMRMACompData_append60saboveB'[CURRENT_QTY])=BLANK(),0,SUM(DRAMRMACompData_append60saboveB[CURRENT_QTY]))

 

Sum of Ext Qty:=if(sum([Extrapolated Qty])=BLANK(),0,sum([Extrapolated Qty]))

 

**bleep** Extr Qty Fails:=calculate(sum(DRAMRMACompData_append60saboveB[Extrapolated Qty]),FILTER(ALLSELECTED('DRAMRMACompData_append60saboveB'),'DRAMRMACompData_append60saboveB'[Year-Month]<=MAX('DRAMRMACompData_append60saboveB'[Year-Month])))

 

My powerpivot table looks like when i drag my measures over to it.  See the blanks in Cumulative Extr Qty Fails where the value for Current Qty is 0?  If there is a 0 in Current Qty, i want the Cumulative Extr Qty Fails to just add 0 and continue as a running total with no blanks.

 

Year-MonthSum of CURRENT_QTYSum of Ext QtyCumulative Extr Qty Fails
2014-1100 
2014-1200 
2015-0100 
2015-0200 
2015-0300 
2015-04154.566210046
2015-052913.69863014
2015-0600 
2015-071518.26484018
2015-0800 
2015-0941129.39726027
2015-1062756.79452055
2015-1100 
2015-1241875.05936073
2016-0134155230.3105023
2016-02627257.7077626
2016-0300 
2016-0415262.2739726
2016-0500 
Grand Total59262262.2739726

 

Any idea what's wrong with my formulas?

@llavey

 

Hi llavey,

 

I cannot reproduce your problem. Both measures provided by Sean and you are working properly with your sample data. My Power BI Version is 2.35.4399.381 64-bit (May 2016). “Cumulative Extr Qty Fails” can always show a cumulative total even when the Sum of Ext Qty = 0.

 

A_Cumulative Extr Qty Fails =

CALCULATE (

    SUM ( 'A'[Sum of Ext Qty] ),

    FILTER ( ALLSELECTED ( 'A' ), A[Year-Month] <= MAX ( 'A'[Year-Month] ) )

)

 

B_Cumulative Extr Qty Fails =

CALCULATE (

    SUM ( B[Sum of Ext Qty] ),

    FILTER (

        ALLSELECTED ( B ),

        B[Year-Month]

            <= MAX ( B[Year-Month] )

    )

)

 

2.jpg

 

Are you working in Power BI Desktop? Please install the latest update Power BI Desktop.

 

If you still can’t make it work, please share the .pbix file if possible.

 

Regards,

if you have a calendar with a relationship you could try this
Cumulative Extr Qty Fails:=calculate(
sum ('A'[Sum of Ext Qty])
,FILTER(all('Calendar'[Date]),
'Calendar'[Date]<=MAX('Calendar'[Date])))

-- ------------------------------ --
Please mark solutions as complete when your question has been answered
-- ------------------------------ --

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors