Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
DouweMeer
Post Prodigy
Post Prodigy

Why doesn't it work? YTD - max (date) vs custom column max (date)

So I'm trying to create a YTD measure and this is :

 

Sales this year =
calculate ( 
   sum ( 'Price_Realisation'[USD Conversion] )
   , filter (
      'Price_Realisation'
      ,'Price_Realisation'[YTD year] = year ( max ( [INVOICE_DT] ) )
      )
   )
 
- USD conversion is the column where all sales was changed to USD.
- YTD column is a custom column that contain an if expression to check if it fits within the ytd date range and returns the year
- Invoice_dt is the actual invoice date. 
 
But apparently this one doesn't work. Creating a separate column with max ([invoice_dt]) seems to be working. 
 
Sales past year =
calculate (
   sum ( 'Price_Realisation'[USD Conversion] )
   , filter (
      'Price_Realisation'
      , 'Price_Realisation'[YTD year] = year ( 'Price_Realisation'[Max date] )
      )
   )
 
Can someone explain me why this is the case? I'm figuring that it has to do with that it searches the max date within a selection that is being filtered. 
1 ACCEPTED SOLUTION
v-frfei-msft
Community Support
Community Support

Hi @DouweMeer,

 

In your first  formula, we can only get the max year or the current row by max ( [INVOICE_DT] ). So we should update your formula as below.

 

Sales this year =
VAR _maxyear =
    YEAR ( MAXX ( ALL ( yourTABLE ), [INVOICE_DT] ) )
RETURN
    CALCULATE (
        SUM ( 'Price_Realisation'[USD Conversion] ),
        FILTER ( 'Price_Realisation', 'Price_Realisation'[YTD year] = _maxyear )
    )

If any other issue, kindly share your sample data and excepted result to me, if you don't have confidential data? Please upload your file to One Drive and share the link here.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

2 REPLIES 2
v-frfei-msft
Community Support
Community Support

Hi @DouweMeer,

 

In your first  formula, we can only get the max year or the current row by max ( [INVOICE_DT] ). So we should update your formula as below.

 

Sales this year =
VAR _maxyear =
    YEAR ( MAXX ( ALL ( yourTABLE ), [INVOICE_DT] ) )
RETURN
    CALCULATE (
        SUM ( 'Price_Realisation'[USD Conversion] ),
        FILTER ( 'Price_Realisation', 'Price_Realisation'[YTD year] = _maxyear )
    )

If any other issue, kindly share your sample data and excepted result to me, if you don't have confidential data? Please upload your file to One Drive and share the link here.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

That actually looks very logical. I notice more and more that even though DAX looks a lot like Excel, it isn't Excel :). Thanks. 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.