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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
jrodriguez
Regular Visitor

Picking MAX date from 3 date columns

Hey Guys,

 

Can you help me with the following? I need syntax that gives me the most recent date from 3 different date columns.....something like this: 

 

Opend Date:      Pending Date:      Close Date:         Max Date from the 3:

    1/2/2015               1/4/2015            1/5/2015                          

 

In tableau it's just a max function. Let me know if you can help me out. Thanks guys

 

Joe

1 ACCEPTED SOLUTION
asocorro
Skilled Sharer
Skilled Sharer

Well, if it's just 3, try this:

 

 

SWITCH(True(),

D1 > D2, IF(D1 > D3, D1, D3),

True(), IF(D2 > D3, D2, D3)
)

 

And in case your data is from SQL Server, you can calculate it in the query.  For example:

 

img3.png

Connect with me in LinkedIn: https://pr.linkedin.com/in/adolfosocorro
Follow me on Twitter: https://twitter.com/AdolfoSocorro

View solution in original post

3 REPLIES 3
asocorro
Skilled Sharer
Skilled Sharer

Well, if it's just 3, try this:

 

 

SWITCH(True(),

D1 > D2, IF(D1 > D3, D1, D3),

True(), IF(D2 > D3, D2, D3)
)

 

And in case your data is from SQL Server, you can calculate it in the query.  For example:

 

img3.png

Connect with me in LinkedIn: https://pr.linkedin.com/in/adolfosocorro
Follow me on Twitter: https://twitter.com/AdolfoSocorro

If you would do this in the query editor instead, your M-code would actually resemble the Tableau syntax:

 

List.Max({[#"Opend Date:"],[#"Pending Date:"],[#"Close Date:"]})

 

There are some performance aspects of M vs DAX as well.

https://blog.oraylis.de/2016/02/relative-week-colu​mn-with-dax-power-query/

 

"...Actually the Power Query version is slightly faster, because the Vertipaq-Engine can do a better compression with a column which is set during data load. The DAX generated columns will be created during processing the model. This has two negative impacts. First the compression won’t be as good and second every time the cube is processed, for example when a new measure is created, Power BI Desktop will recreate the two columns, which will take more time..."

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Anyone any idea why the editor keeps eating the closing brackets?

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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