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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
C4L84
Advocate II
Advocate II

M Language dynamic max year value

Hi all - total M newbie here!

 

I think this ought to be a simple question to answer but I can't find anything online that helps me in this specific scenario.

 

I need to dynamically filter to max year value.

 

Here's the code as it is:

#"Removed Other Columns" = Table.SelectColumns(Source,{"Date", "Order type", "Amount"}),
#"Merged Queries" = Table.NestedJoin(#"Removed Other Columns", {"Date"}, Calendar, {"Date"}, "Calendar", JoinKind.LeftOuter),
#"Expanded Calendar" = Table.ExpandTableColumn(#"Merged Queries", "Calendar", {"Financial Year"}, {"Calendar.Financial Year"}),
#"Filtered Rows" = Table.SelectRows(#"Expanded Calendar", each ([Calendar.Financial Year] = 2021))

 

I changed the last part to:

= Table.SelectRows(#"Expanded Calendar", each ([Calendar.Financial Year] = List.Max([Calendar.Financial Year])))

 

But I am getting this error:

C4L84_0-1626440650100.png

 

How do I filter to the max value of [Calendar.Financial Year]?

 

Thank you

1 ACCEPTED SOLUTION
Anonymous
Not applicable

That was close!  Your 'each' statement causes the second [Calendar.Financial Year] to be a single value, not the entire coulmn as a list.  Here's how it will work:

 

#"Filtered Rows" =  Table.SelectRows(#"Expanded Calendar", let latest = List.Max(#"Expanded Calendar"[Calendar.Financial Year]) in each [Calendar.Financial Year] = latest)

 

--Nate

View solution in original post

2 REPLIES 2
C4L84
Advocate II
Advocate II

Cool! I was wondering how to set it as a variable.

 

Thank you for taking the time to answer, I really appreciate it.

Anonymous
Not applicable

That was close!  Your 'each' statement causes the second [Calendar.Financial Year] to be a single value, not the entire coulmn as a list.  Here's how it will work:

 

#"Filtered Rows" =  Table.SelectRows(#"Expanded Calendar", let latest = List.Max(#"Expanded Calendar"[Calendar.Financial Year]) in each [Calendar.Financial Year] = latest)

 

--Nate

Helpful resources

Announcements
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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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