Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Calculate MAX Date based year context

Hello, 

 

I need some help embedding the Financial year context into a DAX measure:

 

The below measure understandably brings back P13 21/22 as im asking for the MAX Number, im unsure as to how to add in year/financial year context as the correct Max_period should be P04 22/23?

 

Max_Period = 


var Max_Period = calculate(MAX('Alex Date Period Flow'[Period - Numbered]), ALLSELECTED('Alex Date Period Flow'))

return Max_Period

 

 

 

Any assistance would be greatly appreciated.


Thank you!

 

Alex

 

  • johnt75's avatar
    johnt75
    4 years ago

    If the slicer you are using is also coming from the date table then I think the below should work

    Max Period = SELECTCOLUMNS( TOPN(1, 'Date', 'Date'[Date]), 'Date'[Period])

6 Replies

  • You can use TOPN, something like

    Max Period = SELECTCOLUMNS( TOPN(1, 'Table', 'Table'[Fin Year Period]), 'Table'[Period number])

    You may need to change the [Fin Year Period] column to instead be whichever column is providing the Sort Order for that column

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi johnt75 ,

       

      Thank you for taking the time to respond, greatly appreciated!

       

      I'm struggling to get the formula to work, below is my current date table for context. Does my Financial year need to be amended into a whole number? 

       

      Kind regards,

       

      • johnt75's avatar
        johnt75
        Super User

        If the slicer you are using is also coming from the date table then I think the below should work

        Max Period = SELECTCOLUMNS( TOPN(1, 'Date', 'Date'[Date]), 'Date'[Period])