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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
BIuser09
Helper I
Helper I

running total goes wrong

Hi

 

Struggling for some time now in this issue.

Would like to have a running sum on measure delta like matrix below.

Delta works fine. is based on measure 1 and 2. 

Measure 2 is special: data depends on calendar!YearMonth: 

     data previous month (202504) is something else compared to current month and later

YearMonth are also columns in matrix.

Running total measure goes wrong. It adds up measure1 instead of measure delta.

 

Any suggestions ?

 

Should be          
 202504202505202506202507202508202509202510202511202512 
measure1100100100100100100100100100 
measure2506060606060606060 
measure delta504040404040404040 
running total 5090130170210250290330370 
           
But is          
 202504202505202506202507202508202509202510202511202512 
measure1100100100100100100100100100 
measure2506060606060606060 
measure delta504040404040404040 
running total50150250350450550650750850 
           
measure2 =if( SELECTEDVALUE('Calendar'[YearMonth]) >= VALUE(CONCATENATE(YEAR(now()), FORMAT(MONTH(now()),"00")) ),
     [measure_X]        
     ,         
     [measure_Y]        
 )         
           
measure delta =measure1 - measure2       
           
running total =    CALCULATE(        
         [measure delta],       
         FILTER(        
             ALLSELECTED('Calendar'[YearMonth]),    
             'Calendar'[YearMonth] <= MAX('Calendar'[YearMonth])   
         )        
     )         
1 ACCEPTED SOLUTION
v-pnaroju-msft
Community Support
Community Support

Hi @BIuser09,

We appreciate your inquiry submitted through the Microsoft Fabric Community Forum.

Kindly find attached the screenshot and PBIX file, which may assist in resolving the issue:

vpnarojumsft_0-1747370936733.png

If you find our response helpful, we would be grateful if you could mark it as the accepted solution and provide kudos. This will be beneficial to other community members facing similar queries.

Should you have any further questions, please do not hesitate to contact the Microsoft Fabric community.

Thank you.

View solution in original post

3 REPLIES 3
BIuser09
Helper I
Helper I

Before this solution, I also tried to use virtual tables to get the correct running total.

This worked out when I converted the virtual table to a real table but I was not able to transfer the result into my matrix.

I'm wondering what I did wrong here ?

See below the DAX:

 

TableCumBacklog = 
VAR curM = VALUE(CONCATENATE(YEAR(now()), FORMAT(MONTH(now()),"00")) )
VAR prevM = IF(MONTH(today())=1,
    VALUE(CONCATENATE(YEAR(today())-1, "12")),
    VALUE(CONCATENATE(YEAR(today()), FORMAT(MONTH(TODAY())-1,"00")))
)

VAR T1 = SUMMARIZE(
        FILTER(ALL(DATA),VALUE([Month]) >= prevM), 
        'Calendar'[YearMonth],
        "measure1", CALCULATE(sum(DATA[Value]), DATA[Measure] = "1"),
        "measure_X", CALCULATE(sum(DATA[Value]), DATA[Measure] = "X"),
        "measure_Y", CALCULATE(sum(DATA[Value]), DATA[Measure] = "Y"),
    )
VAR T2 = ADDCOLUMNS(T1, "measure2", if(VALUE([YearMonth]) < curM, [measure_X], [measure_Y]) )
VAR T3 = ADDCOLUMNS(T2, "Delta", [measure1]-[ measure2] )
VAR T4 = ADDCOLUMNS(T3,"RunningTotal", SUMX(FILTER(T3, [YearMonth]<=EARLIER([YearMonth])), [Delta]) )
RETURN
     --T4 : shows in table view (create table) ==> correct running total
     --SUMX(T4,[RunningTotal]) : shows only delta’s per YearMonth
     --MAXX(T4,[RunningTotal]) : shows only delta’s per YearMonth
     --SELECTCOLUMNS(T4," ", [RunningTotal]) : shows only delta’s per YearMonth


 

BIuser09
Helper I
Helper I

Bingo !! Thanks ! 

most DAX running total examples just show calculate without SUMX.

 

v-pnaroju-msft
Community Support
Community Support

Hi @BIuser09,

We appreciate your inquiry submitted through the Microsoft Fabric Community Forum.

Kindly find attached the screenshot and PBIX file, which may assist in resolving the issue:

vpnarojumsft_0-1747370936733.png

If you find our response helpful, we would be grateful if you could mark it as the accepted solution and provide kudos. This will be beneficial to other community members facing similar queries.

Should you have any further questions, please do not hesitate to contact the Microsoft Fabric community.

Thank you.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors