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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply
Anonymous
Not applicable

YTD Cumulative

Hello,

I would like to make a YTD Cumulative by year without taking into account the year that is in my filter. For example if I filter on April 2022, to have the YTD accumulation that appears on 2020/2021/2022.

Would you know?

1 ACCEPTED SOLUTION

Hi, @Anonymous 

 

You can create a new date table without establishing a relationship between the two tables. Please refer to the attachment for sample data.

Measure = 
VAR _maxyear = CALCULATE ( SUM ( 'Table'[Value] ),
        FILTER ( ALL ( 'Table' ),
            [Year] = MAX ( 'Table'[Year] )
                && [Month] <= SELECTEDVALUE ( 'Date'[Month] ) ) )
VAR _otheryear = CALCULATE ( SUM ( 'Table'[Value] ),
        FILTER ( ALL ( 'Table' ), [Year] = SELECTEDVALUE ( 'Table'[Year] ) ) )
RETURN
    IF ( SELECTEDVALUE ( 'Table'[Year] )
            = CALCULATE ( MAX ( 'Table'[Year] ), ALL ( 'Table' ) ),
        _maxyear,
        _otheryear
    )

Result:

vzhangti_0-1672900624173.pngvzhangti_1-1672900635488.png

The choice of year does not change the values for 2020 and 2021.

vzhangti_2-1672900689032.png

Only the choice of month will change the cumulative value for 2022.

 

Best Regards,

Community Support Team _Charlotte

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

3 REPLIES 3
Anonymous
Not applicable

Thanks for your help

 

But what I need is a cumulative based on month no matter year filter.

 

For example, I click on April 2020, I need to get the countrows for April 2020, 2021,2022.Image.png

Hi, @Anonymous 

 

You can create a new date table without establishing a relationship between the two tables. Please refer to the attachment for sample data.

Measure = 
VAR _maxyear = CALCULATE ( SUM ( 'Table'[Value] ),
        FILTER ( ALL ( 'Table' ),
            [Year] = MAX ( 'Table'[Year] )
                && [Month] <= SELECTEDVALUE ( 'Date'[Month] ) ) )
VAR _otheryear = CALCULATE ( SUM ( 'Table'[Value] ),
        FILTER ( ALL ( 'Table' ), [Year] = SELECTEDVALUE ( 'Table'[Year] ) ) )
RETURN
    IF ( SELECTEDVALUE ( 'Table'[Year] )
            = CALCULATE ( MAX ( 'Table'[Year] ), ALL ( 'Table' ) ),
        _maxyear,
        _otheryear
    )

Result:

vzhangti_0-1672900624173.pngvzhangti_1-1672900635488.png

The choice of year does not change the values for 2020 and 2021.

vzhangti_2-1672900689032.png

Only the choice of month will change the cumulative value for 2022.

 

Best Regards,

Community Support Team _Charlotte

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

amitchandak
Super User
Super User

@Anonymous , I think you need cumulative 

 

with help from date table

 

Cumm Sales = CALCULATE(SUM(Sales[Sales Amount]),filter(all('Date'),'Date'[date] <=max('Date'[date])))

 

 

or refer window function

 

Window function Rolling, Cumulative/Running Total, WTD, MTD, QTD, YTD, FYTD: https://youtu.be/nxc_IWl-tTc

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

Check out the March 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors