Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
Solved! Go to Solution.
Hi @SJHardeman
First, here's a bit of an explanation of what's going on:
Here is a good article on this overall topic:
https://www.sqlbi.com/articles/understanding-context-transition-in-dax/
A couple of side points:
You can fix this a few ways. I would personally recommend creating these measures:
FTE Sum =
SUM ( data[FTE] )
FTE First Month =
CALCULATE(
[FTE Sum],
FIRSTDATE ( data[Period] )
)
FTE Last Month =
CALCULATE(
[FTE Sum],
LASTDATE ( data[Period] )
)
FTE_change =
[FTE Last Month] - [FTE First Month]
Does this work for you?
Regards
Hi again @SJHardeman
This should work:
FTE Penultimate Month =
CALCULATE (
[FTE Sum],
PREVIOUSMONTH (
LASTDATE ( Staff_Collated_HQ_WFPT[Period] )
)
)
Notes:
As a general comment, I would highly recommend creating a Date/Calendar dimension table and using it for all date filtering.
(See this article for example https://www.daxpatterns.com/standard-time-related-calculations/)
This is because time intelligence functions such as LASTDATE and PREVIOUSMONTH base their logic on dates that exist in the date column provided (in your case the Period column). With more complex date filters, things can go awry if you don't have a Date table with contiguous dates and complete months that is marked as a date table.
Regards
Hi @SJHardeman
First, here's a bit of an explanation of what's going on:
Here is a good article on this overall topic:
https://www.sqlbi.com/articles/understanding-context-transition-in-dax/
A couple of side points:
You can fix this a few ways. I would personally recommend creating these measures:
FTE Sum =
SUM ( data[FTE] )
FTE First Month =
CALCULATE(
[FTE Sum],
FIRSTDATE ( data[Period] )
)
FTE Last Month =
CALCULATE(
[FTE Sum],
LASTDATE ( data[Period] )
)
FTE_change =
[FTE Last Month] - [FTE First Month]
Does this work for you?
Regards
Hi Owen, thanks for explaining this so clearly. The solution worked. Thanks, Sam
Hi @OwenAuger, how would I modify the code if I wanted to also have another measure which calculated FTE_change for [FTE Last Month] - [FTE Penultimate Month]. Using the below
User | Count |
---|---|
70 | |
43 | |
21 | |
21 | |
13 |
User | Count |
---|---|
124 | |
42 | |
39 | |
28 | |
25 |