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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

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

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
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])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.