Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I have implemented the following DATESINPERIOD pattern:
Design Area Avg Previous Period (converted) =
SWITCH(
TRUE(),
ISINSCOPE( 'Date'[Date] ),
CALCULATE( [Design Area Avg (sum)] , DATEADD( 'Date'[Date], -1, DAY )),
ISINSCOPE( 'Date'[Fiscal Month] ),
CALCULATE( [Design Area Avg (sum)], DATEADD( 'Date'[Date], -1, MONTH )),
ISINSCOPE( 'Date'[Fiscal Quarter] ),
CALCULATE( [Design Area Avg (sum)] , DATEADD( 'Date'[Date], -1, QUARTER )),
ISINSCOPE( 'Date'[Fiscal Year] ),
CALCULATE( [Design Area Avg (sum)] , DATEADD( 'Date'[Date], -1, YEAR ))
)
Except that in the most recent Year period we can see that the correct value for the previous year is not reported. This is consistent for two different measures, following the same pattern.
My hypothesis (that I'm looking for confirmation of) is that the previous period result for the current year matches the 'exact' period. That is in the context of FY24 for FY23 it is calculating from August 28th, it is not calculating for the entire period of '23.
Is that correct or is there something else going on that I'm either forgotten about or don't know?
Solved! Go to Solution.
Hi @rpiboy_1
Yes, your hypothesis is correct, if I have understood you correctly 🙂
To describe it in more detail:
Because of this behaviour, your 'Date' table should generally include complete years (however years are defined) spanning your required date range.
https://dax.guide/functions/time-intelligence/
If some time intelligence need to be based on partial periods, then there are some examples of handling this here:
https://www.daxpatterns.com/standard-time-related-calculations/
Regards
Hi @rpiboy_1
Yes, your hypothesis is correct, if I have understood you correctly 🙂
To describe it in more detail:
Because of this behaviour, your 'Date' table should generally include complete years (however years are defined) spanning your required date range.
https://dax.guide/functions/time-intelligence/
If some time intelligence need to be based on partial periods, then there are some examples of handling this here:
https://www.daxpatterns.com/standard-time-related-calculations/
Regards
Thanks for confirming. I also did confirm when I manipulated the Date Slicer on the report (duh!). This ultimatly leads to another question which at the moment remains un-resolved. Is it worth going about adding to the measure to automatically calculated the correct overall period, regardless of the presence of a slicer?
In my case I have a date between slicer so the end users can 'narrow' their focus. This of course is what through the DATESINPERIOD measure off. Therefore, should I consider calculating the full year, quarter and month span of the 'latest' of each so that the previous period is complete?
This is really more of a UX question, though I'm also a bit uncertain the best technical approach.
I took a look at 'end of year' and 'end of month' etc. in dax.guide, and I wasn't entirely certain of the best way to go about getting the right data to pass to the DATEADD function. I'm confident the technical aspect could be resolved, but this leaves oustanding the question of 'should it be', or should I simply ensure Report consumers are educated as to what to expect when they do manipulate the Date Slicer?
Just realised I didn't get back to you on this one 🙂
As far as the UX question, some sort of conditional formatting (e.g. background colour) might be a good way of flagging partial periods. This would require a measure with logic to detect partial periods.
To convert partial to full periods, take a look at PARALLELPERIOD which would be my go-to function. It expands a given date range to complete months/quarters/years and shifts if needed. You may want to combine it with DATEADD or other functions.
User | Count |
---|---|
25 | |
12 | |
8 | |
7 | |
7 |
User | Count |
---|---|
27 | |
12 | |
11 | |
10 | |
6 |