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.
I have a matrix to compare the sales of the past week (week 37) and the same week last year as such:
PY_SalesAmt = CALCULATE(sum(Sales[NetAmount]),DC03_Calendar[Fin_Year] = "2017")
The problem I am encountering is that instead of pulling the data from last year week 37 it is pulling the data from last year week 38.
How can I make an adjustment so these dates line up properly? My last fiscal year is 53 weeks which i believe is the problem.
Solved! Go to Solution.
Hi @igibson,
According to my test, DATAADD and SAMEPERIODLASTYEAR both have a granularity of DAY. Maybe we have to get the same week by ourselves if you want the exact same week (same week number).
CouldbeRight = VAR currentWeeknum = MIN ( 'Date'[Weeknum] ) VAR currentYear = YEAR ( MIN ( 'Date'[Date] ) ) RETURN CALCULATE ( FIRSTDATE ( 'Date'[Date] ), FILTER ( ALL ( 'Date' ), 'Date'[Weeknum] = currentWeeknum && YEAR ( 'Date'[Date] ) = currentYear - 1 ) )
As we can see from the picture, the first day of week 52 of 2010 is 12/19/2010, not 12/18/2010.
Best Regards!
Dale
A very simple soultion that I implemented was a change in the calendar. I simply used Fin_Week = WEEKNUM(DC03_Calendar[Date]+1,21).
A very simple soultion that I implemented was a change in the calendar. I simply used Fin_Week = WEEKNUM(DC03_Calendar[Date]+1,21).
Hi @igibson,
Could you please mark the proper answer as solution or share the solution if it's convenient for you? That will be a big help to the others.
Best Regards!
Dale
Hi @igibson,
According to my test, DATAADD and SAMEPERIODLASTYEAR both have a granularity of DAY. Maybe we have to get the same week by ourselves if you want the exact same week (same week number).
CouldbeRight = VAR currentWeeknum = MIN ( 'Date'[Weeknum] ) VAR currentYear = YEAR ( MIN ( 'Date'[Date] ) ) RETURN CALCULATE ( FIRSTDATE ( 'Date'[Date] ), FILTER ( ALL ( 'Date' ), 'Date'[Weeknum] = currentWeeknum && YEAR ( 'Date'[Date] ) = currentYear - 1 ) )
As we can see from the picture, the first day of week 52 of 2010 is 12/19/2010, not 12/18/2010.
Best Regards!
Dale
Hi,
If in your filter, you have chosen a specific date range, then use the SAMEPERIODLASTYEAR() function in the CALCULATE function.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
108 | |
100 | |
78 | |
64 | |
58 |
User | Count |
---|---|
148 | |
111 | |
94 | |
84 | |
67 |