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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
topazz11
Helper III
Helper III

Max date in power query

I have 3 date columns and like to add max date per each row.

How do I achieve this in power query or can i created as a column not measure?

 

Thank you!

 

datetest.png

2 ACCEPTED SOLUTIONS
grantsamborn
Solution Sage
Solution Sage

Hi @topazz11 

If you have a finite number of date columns, you could try adding a custom column something like this.

 

if [date1] > [date2] then 
    if [date1] > [date3] then [date1] else [date3]
else 
    if [date2] > [date3] then [date2] else [date3]

 

If you aren't sure how many dates in a record, that makes things tougher.

Let me know if this helps.

View solution in original post

Ashish_Mathur
Super User
Super User

Hi,

This M code works

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"id", Int64.Type}, {"date1", type datetime}, {"date2", type datetime}, {"date3", type datetime}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each List.Max(List.Skip(Record.ToList(_),1)))
in
    #"Added Custom"

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

This M code works

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"id", Int64.Type}, {"date1", type datetime}, {"date2", type datetime}, {"date3", type datetime}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each List.Max(List.Skip(Record.ToList(_),1)))
in
    #"Added Custom"

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Very nice, @Ashish_Mathur !

Thank you.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
grantsamborn
Solution Sage
Solution Sage

Hi @topazz11 

If you have a finite number of date columns, you could try adding a custom column something like this.

 

if [date1] > [date2] then 
    if [date1] > [date3] then [date1] else [date3]
else 
    if [date2] > [date3] then [date2] else [date3]

 

If you aren't sure how many dates in a record, that makes things tougher.

Let me know if this helps.

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!

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.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.