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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote 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
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.