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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register 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
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.