cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
jagdishpatil Frequent Visitor
Frequent Visitor

YTD and YTD prior

Hello,

 

I am trying to pull in an average YTD and YTD prior year up to Jan 6th in a bar graph. I am able to pull in the YTD using the =TOTALYTD (AVERAGE(.....)) formula, but can anyone please help to figure out how to pull the average YTD prior year for the same period in Desktop Power BI? I am trying to pull both the YTD and YTD prior year in a same bar graph.

 

01/06/171
01/05/171
01/04/172
01/03/173
01/02/173
01/01/171
01/31/161
01/30/165
01/29/164
01/28/162
01/27/164
01/26/167
01/25/166
01/24/165
01/23/166
01/22/169
01/21/168
01/20/167
01/19/166
01/18/164
01/17/161
01/16/162
01/15/165
01/14/164
01/13/162
01/12/163
01/11/161
01/10/165
01/09/164
01/08/163
01/07/161
01/06/161
01/05/161
01/04/161
01/03/162
01/02/163
01/01/161
1 ACCEPTED SOLUTION

Accepted Solutions
Microsoft v-huizhn-msft
Microsoft

Re: YTD and YTD prior

Hi @jagdishpatil,

I try to reproduce your scenario and get expected result.

First, create measure to calculate YTD and prvious YTD value.

average = TOTALYTD(AVERAGE(Table2[Value]),Table2[Date])

Prior = CALCULATE(Table2[average],SAMEPERIODLASTYEAR(Table2[Date]))


Then create a stacked column chart and add the two measures above as value levels, please see the following screenshot.

2.PNG

Please feel free to ask if you have other issue.

Best Regards,
Angelia

View solution in original post

6 REPLIES 6
dedelman_clng New Contributor
New Contributor

Re: YTD and YTD prior

Try

 

CALCULATE( TOTALYTD( AVERAGE...), SAMEPERIODLASTYEAR( [DateCol] ) )

 

Hope this helps

David

mattbrice Senior Member
Senior Member

Re: YTD and YTD prior

or:

 

TOTALYTD( AVERAGE( Table[Column] ), SAMEPERIODLASTYEAR ( Calendar[Date] ) )
Microsoft v-huizhn-msft
Microsoft

Re: YTD and YTD prior

Hi @jagdishpatil,

I try to reproduce your scenario and get expected result.

First, create measure to calculate YTD and prvious YTD value.

average = TOTALYTD(AVERAGE(Table2[Value]),Table2[Date])

Prior = CALCULATE(Table2[average],SAMEPERIODLASTYEAR(Table2[Date]))


Then create a stacked column chart and add the two measures above as value levels, please see the following screenshot.

2.PNG

Please feel free to ask if you have other issue.

Best Regards,
Angelia

View solution in original post

lerodriguez Frequent Visitor
Frequent Visitor

Re: YTD and YTD prior

In the solutions offered above the DAX formula "SAMEPERIODLASTYEAR" is used to generated Prior Year YTD. However, for my case i cannot use SAMEPERIODLASTYEAR because it doesn't allow for "true/false" comparisons as the conditions is a column. wondering if anyone has an idea on how to circunvent this issue. 

dedelman_clng New Contributor
New Contributor

Re: YTD and YTD prior

Hi @lerodriguez  - as this thread is almost 3 years old it is better to start a new thread than reply to this one. That way you can give all of the details you need and we can focus on solving your particular issue.

Helpful resources

Announcements
Exclusive LIVE Community Event #3 – Ask Arun Anything

Exclusive LIVE Community Event #3 – Ask Arun Anything

Join us in the third Triple A event!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

January 2020 Community Highlights

January 2020 Community Highlights

Make sure you didn't miss any of the things that happened in the community in January!

Top Solution Authors
Top Kudoed Authors