Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hi,
I struggle with a graph, I can't seem to find the solution on the forum.
I have graph showing monthly revenues per year :
For the current month (ie. September), I would like to have the month to date revenue, but same date range for that month in previous years:
1 - 15 sept 2021 vs. 1 - 15 sept 2020 vs. 1 - 15 sept 2019 etc.
with date range automatically growing every day.
Any ideas?
Many thanks
Jo
Solved! Go to Solution.
@Jo_Chrq I did have an error in that formula:
Measure =
VAR __MaxDate = MAX('Dates'[Date]) //if this is 9/15/2021 in filter context
VAR __MinDate = MIN('Dates'[Date]) //if this is 9/1/2021 in filter context
VAR __PreviousYearMax = DATE(YEAR(__MaxDate)-1,MONTH(__MaxDate),DAY(__MaxDate)) //this is 9/15/2020 because the DAY will be 15, month is 9 and year is 2021 - 1
VAR __PreviousYearMin = DATE(YEAR(__MinDate)-1,MONTH(__MinDate),DAY(__MinDate)) //this is 9/1/2020 because DAY is 1, month is 9 and year is 2021 - 1
RETURN
SUMX(FILTER('Table',[Date]<=__PreviousYearMax && [Date]>=__PreviousYearMin),[Value])
@Jo_Chrq You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000
Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.
https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...
In your case, I imagine something like:
Measure =
VAR __MaxDate = MAX('Dates'[Date])
VAR __MinDate = MIN('Dates'[Date])
VAR __PreviousYearMax = DATE(YEAR(__MaxDate)-1,MONTH(__MaxDate),DAY(__MaxDate))
VAR __PreviousYearMin = DATE(YEAR(__MinDate)-1,MONTH(__MinDate),DAY(__MinDate))
RETURN
SUMX(FILTER('Table',[Date]<=__MaxDate && [Date]>=__MinDate),[Value])
Hi Greg thanks for your reply.
Unfortunately this doesn't work for (unless I'm missing something).
I do get the revenue for 1 - 15 Sept 2021 but this keeps the full month's data for preivous year (1 - 30 sept 2020)
@Jo_Chrq I did have an error in that formula:
Measure =
VAR __MaxDate = MAX('Dates'[Date]) //if this is 9/15/2021 in filter context
VAR __MinDate = MIN('Dates'[Date]) //if this is 9/1/2021 in filter context
VAR __PreviousYearMax = DATE(YEAR(__MaxDate)-1,MONTH(__MaxDate),DAY(__MaxDate)) //this is 9/15/2020 because the DAY will be 15, month is 9 and year is 2021 - 1
VAR __PreviousYearMin = DATE(YEAR(__MinDate)-1,MONTH(__MinDate),DAY(__MinDate)) //this is 9/1/2020 because DAY is 1, month is 9 and year is 2021 - 1
RETURN
SUMX(FILTER('Table',[Date]<=__PreviousYearMax && [Date]>=__PreviousYearMin),[Value])