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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
pborah
Continued Contributor
Continued Contributor

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
Continued Contributor
Continued Contributor

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
Continued Contributor
Continued Contributor

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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