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
pawelj795
Post Prodigy
Post Prodigy

Cumulative total over 2 years

Hi,
I have quick question.

Is it possible to create measure which will sum cumulatevily values over 2 years?

I mean it must be something like YTD, but for 2 years, not only one year.

My current measure looks like this:

Spoiler
YTD Revenues =  
CALCULATE(
SUM(
Invent_Trans (Inventory Value);
DATESYTD(DimDates(Date))


My problem arise when 2020 start, so my cumulative Revenues are approximately 0, but I need to sum them with previous year cumulatevily.

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @pawelj795 ,

 

First, one step in the above formula was complicated by me. I have modified it. Please check:

YTD Revenues 5 = 
VAR LastYearFirstDate =
    IF (
        SELECTEDVALUE ( 'Calendar'[Year] ) = BLANK (),
        DATE ( YEAR ( LASTDATE ( Invent_Trans[Date] ) ) - 1, 1, 1 ),
        DATE ( SELECTEDVALUE ( 'Calendar'[Year] ) - 1, 1, 1 ) -------------changed
    )
VAR CurrentDate =
    IF (
        SELECTEDVALUE ( 'Calendar'[Year] ) = BLANK (),
        MAX ( DimDates[Date] ),
        CALCULATE (
            MAX ( DimDates[Date] ),
            FILTER ( DimDates, DimDates[Year] = SELECTEDVALUE ( 'Calendar'[Year] ) )
        )
    )
RETURN
    CALCULATE (
        SUM ( Invent_Trans[Inventory Value] ),
        FILTER (
            ALLSELECTED ( DimDates ),
            DimDates[Date] >= LastYearFirstDate
                && DimDates[Date] <= CurrentDate
        )
    )

Then, you can create your YearWeek column like so:

YearWeek =
CONCATENATE (
    Invent_Trans[Year],
    CONCATENATE ( "  ", FORMAT ( Invent_Trans[WeekNum], "00" ) )
)

 yw.PNG

 

Best Regards,

Icey

 

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

13 REPLIES 13

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.