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 totals in dates with year filter

Hi,

I'm trying to calculate at Running Total over dates and then group by month, quarter and year.

 

I have this measure showing a running total of sales.

It works just fine on regulary dates, but if I group by year or sort out a year it doesn't work anymore:

 

Total Sales Amount RT =
VAR MaxDate = MAX ('Calendar'[Date])
VAR Result =
CALCULATE(
[Total Sales Amount],
'Calendar'[Date]<MaxDate
)
RETURN
Result
 
Here I have filtered out 2022, and I would expect RT to follow and start from 0 but it doesn't. 
 
Krestensb_0-1657890570701.png

What's wrong with my measure?

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

Hi @Anonymous ,

 

Please try this

Total Sales Amount RT =
VAR MaxDate =
    MAX ( 'Calendar'[Date] )
VAR Result =
    CALCULATE (
        [Total Sales Amount],
        FILTER ( ALLSELECTED ( 'Calendar' ), 'Calendar'[Date] < MaxDate )
    )
RETURN
    Result

 

 

Best Regards,

Stephen Tao

 

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

View solution in original post

4 REPLIES 4
v-stephen-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please try this

Total Sales Amount RT =
VAR MaxDate =
    MAX ( 'Calendar'[Date] )
VAR Result =
    CALCULATE (
        [Total Sales Amount],
        FILTER ( ALLSELECTED ( 'Calendar' ), 'Calendar'[Date] < MaxDate )
    )
RETURN
    Result

 

 

Best Regards,

Stephen Tao

 

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

Anonymous
Not applicable

Thanks, but this only works if you are after YTD.

It will start over 1. jan.

I need it to be a running total regardless of the year.

Anonymous
Not applicable
Anonymous
Not applicable

Hi Krestensb,

 

If you want it by year use totalytd, it will do it automatically

 

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.