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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
jagdishpatil
Regular 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
v-huizhn-msft
Microsoft Employee
Microsoft Employee

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
v-huizhn-msft
Microsoft Employee
Microsoft Employee

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

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. 

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.

dedelman_clng
Community Champion
Community Champion

Try

 

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

 

Hope this helps

David

or:

 

TOTALYTD( AVERAGE( Table[Column] ), SAMEPERIODLASTYEAR ( Calendar[Date] ) )

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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