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

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

Reply
finno14
Helper I
Helper I

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

 

 

finno14_0-1655130698877.png

 

Any assistance would be greatly appreciated.


Thank you!

 

Alex

 

1 ACCEPTED SOLUTION

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])

View solution in original post

6 REPLIES 6
johnt75
Super User
Super User

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

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? 

 

finno14_0-1655201467123.png

Kind regards,

 

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])

Hi John, 

 

This formula was spot on, I was trying to display it in a card with a filter within it *Facepalm*

 

Thank you for your help! Lifesaver!!!

 

Alex

Good Morning John,

 

Apologies, I do not mean to be frustrating however I cannot seem to make the code viable... I have attached below so you can see where im going wrong. Apologies again havent too much experience working with TOPN(

 

Max Period = 


  SELECTCOLUMNS(
TOPN(1,'Alex Date Period Flow','Alex Date Period Flow'[Date])
," Select Column requires a name after ( ", 'Alex Date Period Flow'[Period])

That looks OK to me. What results are you seeing? Is it possible to share a sample PBIX ?

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.