Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
I've spent the last couple of days searching this forum, stackoverflow - all of google even used ChatGPT to help write some dax and still I can't get my numbers right.
I have a baseline year of 19/20 and I want to be able to have a comparison of 19/20 YTD based on how many months have passed in the current year. I have a dax measure that "works" but the figure it gives doesn't match what it should be if you just manually filter 19/20 to 11 months which is how many months data I have for 22/23.
I've created a demo file with my baseline YTD measure and data and two tables - one with the baseline YTD measure and another with the baseline data filtered to February 2020 to show what the total figure should be. If anyone can help figure out why on earth the figures aren't matching I will be exceptionally appreciative. Not only would l like to get the correct number (obviously) but also would like to understand what's wrong with my measure as I can't figure it out.
Demo File
Help my Power BI Community, you're my only hope.
Solved! Go to Solution.
@Parosel Here is a measure that will return the desired number:
Baseline YTD 2 =
VAR __Latest = MAX('Actual'[PERIOD])
VAR __BaselineYear = IF(QUARTER(__Latest) = 1, 2020, 2019)
VAR __BaseLineDate = DATE(__BaselineYear, MONTH(__Latest), DAY(__Latest))
VAR __Table = FILTER('Baseline', [PERIOD] <= __BaseLineDate)
VAR __Result = SUMX(__Table, [Sales])
RETURN
__Result
This is based on Better Year To Date Total found here: Better Year to Date Total - Microsoft Power BI Community
The short answer on why your measure is not working is that you are using CALCULATE and even worse that you are using DAX TI functions. DAX TI functions are kind of garbage. My channel has a bunch of videos on this subject.
OK, the long answer, while DATESYTD is one of the few TI functions that actually has some semblance of support for a fiscal year it still has the nasty habit of returning all dates within the current period. Thus, when you call DATESYTD with your Baseline table and your baseline table has dates in March, it's going to return those dates in March even though your actuals only go through February. It's just how that function works. It has no concept that your actuals table only goes through February, it only knows about the Baseline table.
Hopefully this helps.
@Parosel Here is a measure that will return the desired number:
Baseline YTD 2 =
VAR __Latest = MAX('Actual'[PERIOD])
VAR __BaselineYear = IF(QUARTER(__Latest) = 1, 2020, 2019)
VAR __BaseLineDate = DATE(__BaselineYear, MONTH(__Latest), DAY(__Latest))
VAR __Table = FILTER('Baseline', [PERIOD] <= __BaseLineDate)
VAR __Result = SUMX(__Table, [Sales])
RETURN
__Result
This is based on Better Year To Date Total found here: Better Year to Date Total - Microsoft Power BI Community
The short answer on why your measure is not working is that you are using CALCULATE and even worse that you are using DAX TI functions. DAX TI functions are kind of garbage. My channel has a bunch of videos on this subject.
OK, the long answer, while DATESYTD is one of the few TI functions that actually has some semblance of support for a fiscal year it still has the nasty habit of returning all dates within the current period. Thus, when you call DATESYTD with your Baseline table and your baseline table has dates in March, it's going to return those dates in March even though your actuals only go through February. It's just how that function works. It has no concept that your actuals table only goes through February, it only knows about the Baseline table.
Hopefully this helps.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
143 | |
78 | |
63 | |
52 | |
47 |
User | Count |
---|---|
212 | |
82 | |
61 | |
60 | |
58 |