Forum Discussion
Centaur1
1 year agoRegular Visitor
Compare 2 date fields and use Greater than date
Hello, I am a novice user of PQ. I need to compare 2 dates I have: Date1 and Date2 If Date2>=Date1 then use Date2 else use Date1 I added a conditional column but I think the issue is that I ...
dufoq3
1 year agoCommunity Champion
Hi Centaur1, another solution:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjLQNzTUNzIwMlHSUTK0hHNidaKVDE2R5CAixlARU5BqczgnNhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date1 = _t, Date2 = _t]),
ChangedType = Table.TransformColumnTypes(Source,{{"Date1", type date}, {"Date2", type date}}),
Ad_MaxDate = Table.AddColumn(ChangedType, "MaxDate", each List.Max( { [Date2] ?? [Date1], [Date1] } ), type date)
in
Ad_MaxDate