cancel
Showing results for
Did you mean:

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Helper I

## YTD vs YTD Baseline year

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.

1 ACCEPTED SOLUTION
Super User

@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.

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
2 REPLIES 2
Helper I

@Greg_Deckler absolutley brilliant. Thank you kindly!

Super User

@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.

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Announcements

#### New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

#### Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

#### Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors