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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
pborah
Solution Sage
Solution Sage

How to compare current YTD for the same amount of time with previous years?

I'm counting the number of calls received in a call center this year upto present day (YTD, October 8, 2021) and trying to compare them with call volume for the samer time period (i.e. January 1, 2020-October 8,2020) for previous year, and 2 years ago (Jan 1 2019-October 8, 2019). However on cross checking with excel the numbers are different. The idea is to figure out the correct formula for 2 years ago and then just modifying it for last year. I have a date table that is linked to the call_recv_date attribute in the main data table. Please help with below formulae - 

 

YTD Current Year = 

TOTALYTD(COUNT('Reports WeeklyReporting'[evt_rin]),'CALENDAR'[Date]) -> This returns correct number.
 
YTD 2 Years Ago = 
CALCULATE([YTD Current Year], PARALLELPERIOD('CALENDAR'[Date],-2,YEAR)) -> This returns an incorrect count for Jan 1,2019 - October 8,2019
 
Thanks.
 
1 ACCEPTED SOLUTION
pborah
Solution Sage
Solution Sage

Answering my own question here. Everyone suggesting SAMEPERIODLASTYEAR, PARALLELPERIOD (and possibly DATEADD) do not realize that the granularity of these functions do not gown all the way down to a single day. The lowest granularity is down to one month. This is why my last year and 2 years prior YTD figures were inflated by 23 extra days  for prior years(october has 31 days, today is October 8th).  To arrive at the true YTD numbers you will have to set the start and end date for prior year YTD formulas with other logic. One example is - 

 

YTD Two Years Ago =

VAR StartDate = CALCULATE(STARTOFYEAR('CALENDAR'[Date]),'CALENDAR'[Year]=YEAR(TODAY()))
VAR EndDate = MAX('CALENDAR'[Date])
RETURN
CALCULATE([YTD Current Year],'CALENDAR'[Date]>=StartDate-731 && 'CALENDAR'[Date]<=EndDate-731)
 
Another way to filter the dates within CALCULATE is - 
 
'Calendar'[Date] <= DATE(YEAR(TODAY())-2,MONTH(TODAY()),DAY(TODAY())

View solution in original post

1 REPLY 1
pborah
Solution Sage
Solution Sage

Answering my own question here. Everyone suggesting SAMEPERIODLASTYEAR, PARALLELPERIOD (and possibly DATEADD) do not realize that the granularity of these functions do not gown all the way down to a single day. The lowest granularity is down to one month. This is why my last year and 2 years prior YTD figures were inflated by 23 extra days  for prior years(october has 31 days, today is October 8th).  To arrive at the true YTD numbers you will have to set the start and end date for prior year YTD formulas with other logic. One example is - 

 

YTD Two Years Ago =

VAR StartDate = CALCULATE(STARTOFYEAR('CALENDAR'[Date]),'CALENDAR'[Year]=YEAR(TODAY()))
VAR EndDate = MAX('CALENDAR'[Date])
RETURN
CALCULATE([YTD Current Year],'CALENDAR'[Date]>=StartDate-731 && 'CALENDAR'[Date]<=EndDate-731)
 
Another way to filter the dates within CALCULATE is - 
 
'Calendar'[Date] <= DATE(YEAR(TODAY())-2,MONTH(TODAY()),DAY(TODAY())

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 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.