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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.