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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
tfoss78
Regular Visitor

Returning latest among multiple dates by row?

Newer user, apologies in advance if I'm missing something basic here.  The table I'm using includes several dates per row corresponding to the receipt of various documents, I am trying to build a custom column that will return the latest of these dates per row.  It's my sense that MAX on the DAX side is entirely out, I've attempted to use the following script in Power Query to no avail ("a cyclic reference was enountered..."):

 

Table.AddColumn(#"Changed Type", "Custom", each Table.AddColumn(table, "Max", each List.Max({[receipt of document 1], [receipt of document 2], [receipt of document 3], [receipt of document 4], [receipt of document 5], [receipt of document 6], [receipt of document 7]})))

 

I would be eternally grateful to anyone who can set me on the right path!  Thanks very much for reading.

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @tfoss78 ,

There two Table.AddColumn in you code. 

vkalyjmsft_0-1659428110875.png

I get the correct result by add a custom column.

 

List.Max({[Column1],[Column2],[Column3]})

 

vkalyjmsft_1-1659428211568.png

Here's the whole code below, you can copy-paste in a blank query to see the step.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtI31zc0UtKBsxFMM6VYHbgaY4S4EZJyC2Q1SOKmCKalUmwsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type date}, {"Column2", type date}, {"Column3", type date}}),
    #"Added Custom1" = Table.AddColumn(#"Changed Type", "Max", each List.Max({[Column1],[Column2],[Column3]}))
in
    #"Added Custom1"

 

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-yanjiang-msft
Community Support
Community Support

Hi @tfoss78 ,

There two Table.AddColumn in you code. 

vkalyjmsft_0-1659428110875.png

I get the correct result by add a custom column.

 

List.Max({[Column1],[Column2],[Column3]})

 

vkalyjmsft_1-1659428211568.png

Here's the whole code below, you can copy-paste in a blank query to see the step.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtI31zc0UtKBsxFMM6VYHbgaY4S4EZJyC2Q1SOKmCKalUmwsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type date}, {"Column2", type date}, {"Column3", type date}}),
    #"Added Custom1" = Table.AddColumn(#"Changed Type", "Max", each List.Max({[Column1],[Column2],[Column3]}))
in
    #"Added Custom1"

 

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

johnt75
Super User
Super User

You can use MAX, you just need to put the columns into a table variable, like

Max of columns = MAXX( { 'Table'[Col1], 'Table'[Col2], 'Table'[Col3] }, [Value])

Hi John, thanks very much for this bit of insight.  However, I'm encountering a problem with the value part of the expression - I don't need any calculation per se, just that it return the latest among seven dates specified in the first part of the expression.  Is this possible using MAXX?  Sorry if I'm being dim here.  

The table constructor { } creates a table with a single column called [Value]. By adding all the dates you want to compare into a table like that you can run MAXX over it.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.