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
miiihiir
Helper II
Helper II

Running Total for a value in DAX measure

Hello DAX People,
So basically I need to create a Running Total, I have created a measure which is calculating active EMIs(SIP), I have visualized it on the bargraph as well (screenshot attatched).

 

miiihiir_0-1673605597180.png

Calculations for Measure:

Active SIP =
[Total SIP Started] - [Total SIP Stopped/ Completed]
 
Total SIP Started =
CALCULATE(SUM('T_ORDER (For SIP)'[order_amount]), FILTER('T_ORDER (For SIP)', 'T_ORDER (For SIP)'[order_type] = "SIP" && ('T_ORDER (For SIP)'[order_status] = "Executed" || 'T_ORDER (For SIP)'[order_status] = "Running" || 'T_ORDER (For SIP)'[order_status] = "Stopped" || 'T_ORDER (For SIP)'[order_status] = "Completed")))
 
Total SIP Stopped/ Completed =
CALCULATE(SUM('T_ORDER (For SIP)'[order_amount]), FILTER('T_ORDER (For SIP)', 'T_ORDER (For SIP)'[order_type] = "SIP" && ('T_ORDER (For SIP)'[order_status] = "Stopped" || 'T_ORDER (For SIP)'[order_status] = "Completed")))
 

So,

Here one more thing we need to add in this bar graph, is an another bar showing running total of EMIs over months. 
I tried creating the same using this logic:

Cumulative =
CALCULATE([Running SIP], FILTER('T_ORDER (For SIP)', 'T_ORDER (For SIP)'[order_date] <= MAX('T_ORDER (For SIP)'[order_date])))
 
Also used this measure also:
 
Run SIP =
SUMX(FILTER(ALL('T_ORDER (For SIP)'[order_date]), 'T_ORDER (For SIP)'[order_date] <= MAX('T_ORDER (For SIP)'[order_date])), [Running SIP])
 
and both of them are not working for this problem statement, it is showing like this, need runnning total rather than this.

miiihiir_1-1673606002704.png

 

So is there any other logic in your mind which could be working in this scenario?

 

Thanks

Mihir 

1 ACCEPTED SOLUTION

Try Using this measure:

Cummulative SIP =

CALCULATE([Running SIP], FILTER(ALLSELECTED('TableName'), 'TableName'[date] <= MAX('TableName'[date])))

View solution in original post

3 REPLIES 3
v-yueyunzh-msft
Community Support
Community Support

Hi , @miiihiir 

According to your description, you want to calculate the rolling total from a measure?
If this , here are the steps you can refer to :
(1)This is my test data:

vyueyunzhmsft_0-1673840134382.png

(2)We need to create a date table as  a dimension table:

Date = ADDCOLUMNS( 
CALENDAR(FIRSTDATE('Table'[Date]),LASTDATE('Table'[Date])),
"Year", YEAR ( [Date] ),
"Month", MONTH([Date]),
"Year_Month", year([Date]) * 100 + MONTH([Date])
)

And we need to create a relationship between two tables:

vyueyunzhmsft_1-1673840179668.png

In my test measure is this:

My Measure = SUM('Table'[Value])

(3)Then we can create a measure like this:

Rolling Total = var _t = SUMMARIZE(ALLSELECTED('Date') ,'Date'[Year_Month] , "measure" , [My Measure])
var _cur_year_month = MAX('Date'[Year_Month]) 
var _t2 =FILTER(_t , [Year_Month]<=_cur_year_month)
return
SUMX(_t2, [measure])

Then we can get the rolling total:

vyueyunzhmsft_2-1673840237106.png

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

Try Using this measure:

Cummulative SIP =

CALCULATE([Running SIP], FILTER(ALLSELECTED('TableName'), 'TableName'[date] <= MAX('TableName'[date])))
johnt75
Super User
Super User

Try

Run SIP =
VAR MaxDate =
    MAX ( 'T_ORDER (For SIP)'[order_date] )
RETURN
    SUMX (
        FILTER (
            ALL ( 'T_ORDER (For SIP)'[order_date] ),
            'T_ORDER (For SIP)'[order_date] <= MaxDate
        ),
        [Running SIP]
    )

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.

Top Solution Authors