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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

How to find MAX of 4 date fields in a powerquery while developing a PowerBI report

My data looks like this..

PRDTREGDAT1DAT2DAT3DAT4QTY
P1US8/9/201812/9/20171/12/201910/31/2017100
P2EU3/9/20188/29/20179/9/20184/8/2017200
P3US10/1/20183/7/20176/22/20183/17/20173400
P4ME12/20/20189/5/20171/10/201811/14/2017400
P1EU6/19/20187/27/20171/23/20188/15/2018500

 

I am looking for an output like this

PRDTREGMAXDATEQTY
P1US1/12/2019100
P2EU9/9/2018200
P3US10/1/20183400
P4ME12/20/2018400
P1EU8/15/2018500

 

in the powerquery to develop a powerBI dashboard.

 

My query looks like this [ including the 4 date fields in the ouput] . Tried couple of methods but none of them was successful.

 

select
MP."PRODT" "PRDT",
MP."AREA" "REG",
MP."EFFDT" "DAT1",
MP."APPDT" "DAT2",
MP."CONSDT" "DAT3",
MP."ENTDT" "DAT4",
(SELECT Max(v)   FROM
 VALUES ((MP."EFFDT"),( MP."APPDT"), (MP."CONSDT"),(MP."ENTDT")) Value(v)
)

"MaxDate",

MP."quan" "QTY"

from
"_SYS_BIC"."xxxxx" MP
where MP."AREA"  IN ('xxx','yyy') and MP."quan" >0

 

2 REPLIES 2
Zubair_Muhammad
Community Champion
Community Champion

@Anonymous

 

You can add a custom Column like

 

=List.Max({[DAT1],[DAT2],[DAT3],[DAT4]})
Anonymous
Not applicable

I tried the above option by adding a custom column, but it is not giving me the MAX Date on Each record.

 

Infact I was trying to avoid pulling in all these 4 date fields in the query output.

So if I am able to add the MAX Syntax in the power Query (SQL)  itself it would be great.

 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

Top Solution Authors
Top Kudoed Authors