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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
dandreev
Helper I
Helper I

Finding the latest date in dynamic header

Hi All,
I have a table with date headers like:

December 2021November 2021October 2021September 2021

next month headers will change to:

January 2022December 2021November 2021October 2021

Is there a way like a MAX() function that I call a column based on the latest date in the header?

Thank you!

4 REPLIES 4
CNENFRNL
Community Champion
Community Champion

Unpivot dataset, if possible.


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

I did that.I have a viz that require latest month data from a  column with date header. I'm curious to see if it is possible to 'query' headers.  My background is with another less popular profuct that had the option.

Hi, @dandreev 

Not fully sure what you want.

Can you share you sample file for further research?

Best Regards,
Community Support Team _ Eason

 

I'll try to explain.

 

DESCRPTOctober 2021November 2021December 2021
Avalues276319192
Bvalues787345
Cvalues198246147
Dvalues353341218

 

Headers are set to change every month with Power Query code:

 

 

#"Renamed PR_MO_ONE" = Table.RenameColumns(#"Renamed ",{{"PR_MO_ONE", Date.MonthName(Date.AddMonths(DateTime.LocalNow(),-1))&" "& Text.From(Date.Year(Date.AddMonths(DateTime.LocalNow(),-1)))}}),
#"Renamed PR_MO_TWO" = Table.RenameColumns(#"Renamed PR_MO_ONE",{{"PR_MO_TWO", Date.MonthName(Date.AddMonths(DateTime.LocalNow(),-2))&" "& Text.From(Date.Year(Date.AddMonths(DateTime.LocalNow(),-2)))}}),
#"Renamed PR_MO_THREE" = Table.RenameColumns(#"Renamed PR_MO_TWO",{{"PR_MO_THREE", Date.MonthName(Date.AddMonths(DateTime.LocalNow(),-3))&" "& Text.From(Date.Year(Date.AddMonths(DateTime.LocalNow(),-3)))}})

 

 

Let's say I have a barchart that should show values for last month and a line chart that excludes latest month based on headers.
If it is too confusing I'll just close the request.
Thank you!

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!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

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