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

Shape the future of the Fabric Community! Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions. Take survey.

Reply
Anonymous
Not applicable

Selected Month & Year Dax

Hello,

 

I am trying to write a Dax to show the selected year. But when no year is selected in the slicer, I want to the title to show the Max value of the date.

 

I worte: 

12m leading to = "12 months leading to "&SELECTEDVALUE(Dates[Year Month], (MAX(Dates[Year Month])))
However, this shows May 22 as the Max, because the max is based on alphebetical order.  I do have a Data table (please see below) which is created by Dax (Copied from Youtube 😅).  How could I show Aug 22 as the Max by changing the Dax above, please.
Thank you very much
 
Toshie_0-1662646200852.png

 

Dates =
VAR Days = CALENDAR(Min('Service'[Date]), Max ('Service'[Date]))
Return ADDCOLUMNS(
Days,
"Year", YEAR([Date]),
"Month Number", MONTH( [Date]),
"Month", FORMAT ([Date], "mmmm"),
"Year Month Number", Year ([Date])* 12 + MONTH( [Date]) -1,
"Year Month", FORMAT([Date], "mmm yy"), "DateKey", FORMAT([Date], "yyyymmdd"
))
 
 

 

1 ACCEPTED SOLUTION

@Anonymous , Please check parenthesis position in your measure

 

try like

meausre =
var _max = maxx(allselected(dates), Dates[Dates])
return
maxx(filter(Dates, Dates[Date] =_max), dates[year month])

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Thanks @amitchandak This worked! Now my title changes dynamically

Toshie_0-1662708533261.png

 

amitchandak
Super User
Super User

@Anonymous , use in place of

 

SELECTEDVALUE(Dates[Year Month], (MAX(Dates[Year Month])))

 

Use this

maxx(filter(Dates, Dates[Date] = maxx(allselected(dates), Dates[Dates]) ), dates[year month])

 

or

 

maxx(filter(allselected(dates), Dates[Date] = maxx(allselected(dates), Dates[Dates]) ), dates[year month])

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
Anonymous
Not applicable

Thanks @amitchandak for your reply.  I tried both Dax measures, but I get an error message from both.  Am I doing anything wrong?

Thanks

 

Toshie_0-1662652529370.png

Toshie_1-1662652977892.png

 

 

@Anonymous , Please check parenthesis position in your measure

 

try like

meausre =
var _max = maxx(allselected(dates), Dates[Dates])
return
maxx(filter(Dates, Dates[Date] =_max), dates[year month])

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

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.