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
Anonymous
Not applicable

Running Total Not Working

Hi Folks, 

 

I'm trying to get the running total for my tables with date and group filters.

 

Following is the DAX syntax I'm using but it is not giving the correct anwer,

For Column,

 

Running_TotalC =
CALCULATE(
SUM(Data_2[P1Log_Ret]),
FILTER(
ALLEXCEPT(Data_2, Data_2[Group] ,Data_2[ReturnDate]),
Data_2[ReturnDate] <= EARLIER(Data_2[ReturnDate])
)
)
 
And For measure,
 
Running_Total =
CALCULATE(
SUM(Data_2[P1Log_Ret]),
FILTER(
ALLEXCEPT(Data_2, Data_2[PMSAcronym] ,Data_2[ReturnDate]),
Data_2[ReturnDate] <= SELECTEDVALUE(Data_2[ReturnDate])
)
)
 

Could you please help me in this. 

 

 

ReturnDateGroupFundReturnP1Log_RetRunning_TotalC
1/31/2013 0:00A-0.00195227-0.001954178-0.001954178
2/1/2013 0:00A0.0002673380.0002673020.000267302
2/2/2013 0:00A0.0001860130.0001859960.000185996
2/3/2013 0:00A0.0001866610.0001866440.000186644
2/4/2013 0:00A-0.001295777-0.001296618-0.001296618
2/5/2013 0:00A-0.000439921-0.000440018-0.000440018
2/6/2013 0:00A0.000161580.0001615660.000161566
2/7/2013 0:00A-0.000492769-0.00049289-0.00049289
2/8/2013 0:00A0.0005908210.0005906460.000590646
2/9/2013 0:00A0.0001882430.0001882250.000188225
2/10/2013 0:00A0.0001882080.0001881910.000188191
2/11/2013 0:00A-0.000108518-0.000108524-0.000108524
2/12/2013 0:00A3.2959E-063.29589E-063.29589E-06
2/1/2013 0:00B-0.001927674-0.001929534-0.001929534
2/2/2013 0:00B0.0001794520.0001794360.000179436
2/3/2013 0:00B0.0001804870.0001804710.000180471
2/4/2013 0:00B0.0018849930.0018832190.001883219
2/5/2013 0:00B-0.002777571-0.002781436-0.002781436
2/6/2013 0:00B0.0031227460.003117880.00311788
2/7/2013 0:00B0.0004238510.0004237610.000423761
2/8/2013 0:00B-0.000412682-0.000412767-0.000412767
1 ACCEPTED SOLUTION
v-jayw-msft
Community Support
Community Support

Hi @Anonymous ,

 

If i understand you correctly, please modify "ALLEXCEPT(Data_2, Data_2[Group] ,Data_2[ReturnDate])" to "ALLEXCEPT(Data_2, Data_2[Group])".

For Column:

Running_Total_C = 
CALCULATE (
    SUM ( Data_2[P1Log_Ret] ),
    FILTER (
        ALLEXCEPT ( Data_2, Data_2[Group] ),
        Data_2[ReturnDate] <= EARLIER ( Data_2[ReturnDate] )
    )
)

For Measure:

Running_Total_M = 
CALCULATE (
    SUM ( Data_2[P1Log_Ret] ),
    FILTER (
        ALLEXCEPT ( Data_2, Data_2[Group] ),
        Data_2[ReturnDate] <= SELECTEDVALUE ( Data_2[ReturnDate] )
    )
)

Result would be shown as below:

1.PNG2.PNG

BTW, if you want to calculate Running Total per month, please refer to the formula below.

Running_Total_monthly = 
CALCULATE (
    SUM ( Data_2[P1Log_Ret] ),
    FILTER (
        ALLEXCEPT ( Data_2, Data_2[Group] ),
        Data_2[ReturnDate] <= EARLIER ( Data_2[ReturnDate] )
            && FORMAT ( Data_2[ReturnDate], "YYYYMM" )
                = FORMAT ( EARLIER ( Data_2[ReturnDate] ), "YYYYMM" )
    )
)

3.PNG

 

Best Regards,

Jay

Community Support Team _ Jay Wang

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

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

3 REPLIES 3
v-jayw-msft
Community Support
Community Support

Hi @Anonymous ,

 

If i understand you correctly, please modify "ALLEXCEPT(Data_2, Data_2[Group] ,Data_2[ReturnDate])" to "ALLEXCEPT(Data_2, Data_2[Group])".

For Column:

Running_Total_C = 
CALCULATE (
    SUM ( Data_2[P1Log_Ret] ),
    FILTER (
        ALLEXCEPT ( Data_2, Data_2[Group] ),
        Data_2[ReturnDate] <= EARLIER ( Data_2[ReturnDate] )
    )
)

For Measure:

Running_Total_M = 
CALCULATE (
    SUM ( Data_2[P1Log_Ret] ),
    FILTER (
        ALLEXCEPT ( Data_2, Data_2[Group] ),
        Data_2[ReturnDate] <= SELECTEDVALUE ( Data_2[ReturnDate] )
    )
)

Result would be shown as below:

1.PNG2.PNG

BTW, if you want to calculate Running Total per month, please refer to the formula below.

Running_Total_monthly = 
CALCULATE (
    SUM ( Data_2[P1Log_Ret] ),
    FILTER (
        ALLEXCEPT ( Data_2, Data_2[Group] ),
        Data_2[ReturnDate] <= EARLIER ( Data_2[ReturnDate] )
            && FORMAT ( Data_2[ReturnDate], "YYYYMM" )
                = FORMAT ( EARLIER ( Data_2[ReturnDate] ), "YYYYMM" )
    )
)

3.PNG

 

Best Regards,

Jay

Community Support Team _ Jay Wang

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

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

Hi @Anonymous ,

 

did you solve your problem?


If I answered your question, please mark my post as solution, this will also help others.

Please give Kudos for support.

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast


Hi @Anonymous 

 

You may download my PBIX file from here.
Hope this helps.

 

If I answered your question, please mark my post as solution, this will also help others.

Please give Kudos for support.

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast


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.