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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
rp2022
Helper I
Helper I

Running Total / Cummulative totals

Input: 

LabelDateMP$
PD3/2/20244406S7-100
PD3/3/20245102S7100
PD3/4/20246181S0200
PD3/5/20247161S0500
PD3/6/20247385S0-300
PD3/7/20249587S0200
ST3/8/20241000S7400
3/9/20243/9/20241001S7900
3/10/20243/10/20241201S7600
3/11/20243/11/20241201S7700
3/12/20243/12/20241201S7500
3/13/20243/13/20241201S7

-100

 

Output:

LabelDateMP$Running Total 
PD3/2/20244406S7-100-100=E2
PD3/3/20245102S71000=F2+E3
PD3/4/20246181S0200200=F3+E4
PD3/5/20247161S0500700=F4+E5
PD3/6/20247385S0-300400=F5+E6
PD3/7/20249587S0200600=F6+E7
ST3/8/20241000S7400400=E8
3/9/20243/9/20241001S7900900=E9
3/10/20243/10/20241201S76001500=F9+E10
3/11/20243/11/20241201S77002200=F10+E11
3/12/20243/12/20241201S75002700=F11+E12
3/13/20243/13/20241201S7-1002600=F12+E13

 Also, want to able to slice based on columns M, P, Label etc.

Apprciate any help

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

Hi @rp2022 ,

Please create a new calculated column:

Group = 
VAR __cur_label = 'Table'[Label]
VAR __group = IF(ISERROR(VALUE(__cur_label)),__cur_label,"Date")
RETURN
__group

vcgaomsft_0-1710141110538.png

And then please create a new measure:

Running Total = 
VAR __group = MAX('Table'[Group])
VAR __cur_date = MAX('Table'[Date])
VAR __result = CALCULATE(SUM('Table'[$]),FILTER(ALLSELECTED('Table'),'Table'[Group]=__group && 'Table'[Date]<=__cur_date))
RETURN
__result

Output:

vcgaomsft_1-1710141175534.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

View solution in original post

3 REPLIES 3
v-cgao-msft
Community Support
Community Support

Hi @rp2022 ,

Please create a new calculated column:

Group = 
VAR __cur_label = 'Table'[Label]
VAR __group = IF(ISERROR(VALUE(__cur_label)),__cur_label,"Date")
RETURN
__group

vcgaomsft_0-1710141110538.png

And then please create a new measure:

Running Total = 
VAR __group = MAX('Table'[Group])
VAR __cur_date = MAX('Table'[Date])
VAR __result = CALCULATE(SUM('Table'[$]),FILTER(ALLSELECTED('Table'),'Table'[Group]=__group && 'Table'[Date]<=__cur_date))
RETURN
__result

Output:

vcgaomsft_1-1710141175534.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

Works like a charm, thank you so much

Ritaf1983
Super User
Super User

Hi @rp2022 
You can use the DAX measure :

Runing total =
 VAR MaxDate = MAX ( 'Table'[Date] ) -- Saves the last visible date
RETURN
    CALCULATE (
        sum('Table'[$]),            -- Computes  sum of $
        'Table'[Date] <= MaxDate,   -- Where date is before the last visible date
        ALLSELECTED( ( 'Table'[Date] )               -- Removes any other filters from Date
    ))
Ritaf1983_0-1709960384303.png

The pbix is attached

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

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.