YTD vs Full Year

In my attached PBIX sample file, I’ve made up some random data for dates beginning 1/1/2017 through today. I’m trying to show cumulative amounts for the last two years alongside YTD amounts for this year. In my sample, I’m seeing that, but the YTD line shows flat through the end of this year. I need it to stop at the end of the last full month while still showing the lines for the full year on the previous years’ lines.

What I see now…

What I want to see…

I hope that makes sense. Any thoughts on how best to accomplish this?

YTD Test.pbix (135.6 KB)

Hi @DaveC,

The only way I can think of is dropping the YTD TY line to 0 from March because that is the last month that contains values. Then make a constant black line on value 0 to hide the YTD TY line where it’s 0. It’s not the most elegant way I think, but maybe it’s useful.

solid

Hope is helps.

Daniel

Hi Dave,

I’ve added a “CompletedMonth” column to your Dates table, like so:

With this in place, I added a copy of your YTD TY measure (needed because of the measure branching)

YTD TY V2 = 
IF( VALUES( Dates[CompletedMonth] ) = TRUE(),
    [YTD TY],
    BLANK()
)

With this result.

Here’s your file. I hope this was helpful.
YTD Test.pbix (156.4 KB)

2 Likes

This is an elegant solution. Nice and clean.:slight_smile:

1 Like

@DaveC, @uriah1977,

Here’s another approach:

 YTD TY Display = 

VAR CurrentMonthNum =
MONTH( TODAY() )

RETURN
IF( 
    SELECTEDVALUE( Dates[MonthOfYear] ) > CurrentMonthNum,
    BLANK(),
    [YTD TY]
) 

Now use this in your visual instead of YTD TY (but rename it in the values box of the visual, so that the legend reads properly:

Hope this is helpful.

2 Likes

This forum is a treasure chest :smile:

@Melissa and @BrianJ,

Thanks for the great solutions! Right before seeing your replies, I came up with a working solution that is a similar line of thinking although less elegantly written:

YTD TY v2 = 
IF(MAX(Dates[Date]) <= EOMONTH(TODAY(), -1), 
    CALCULATE( [Total Amount],
        DATESBETWEEN(Dates[Date],
            DATE(YEAR(MAX(Dates[Date])), 1, 1),
            MAX(Dates[Date])
        )
    ),
    BLANK()
) 

Glad to see that I at least had the right thought process! Thanks again for the quick replies!

2 Likes

@uriah1977,

This forum is a treasure chest :smile:

Could not agree more. Four different people with exactly the same tools, four completely different solutions. That’s why I find this endlessly fascinating…

  • Brian

P.S. And a fifth one for good measure:

1 Like