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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
youngmasterRD
New Member

DAX to Power Query

Hello all!

 

Currently, I have this formula in my DAX.

 

 

Status = FILTER(ALL(raw),[Timestamp]=CALCULATE(MAX(raw[Timestamp],ALLEXCEPT(raw,raw[ID])))

 

 

How can I have a same outcome in Power Query?

 

Raw table

IDTimestampStatus
00011st December 2021New
00012nd December 2021In-Progress
00015th December 2021Completed
00022nd December 2021New
00023rd December 2021In-Progress

 

Processed table

IDTimestampStatus
00015th December 2021Completed
00023rd December 2021In-Progress

 

Thanks in advance!

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @youngmasterRD ,

 

You need to group your raw table on [ID] with the All Rows aggregator, then grab the row that features the MAX of [Timestamp].

 

Example query code:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjAwMFTSUTIsLlFwSU1OzU1KLVIwMjACifmllivF6sCVGOWlYCjxzNMNKMpPL0otLkZWalqSgaHUOT+3ICe1JDUFptAIh5lI1oKUGBcRsDYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Timestamp = _t, Status = _t]),
    chgTypes = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Timestamp", type text}, {"Status", type text}}),
    groupId = Table.Group(chgTypes, {"ID"}, {{"data", each _, type table [ID=nullable number, Timestamp=nullable text, Status=nullable text]}}),
    addMaxRecord = Table.AddColumn(groupId, "maxRecord", each Table.Max([data], "Timestamp")),
    expandMaxRecord = Table.ExpandRecordColumn(addMaxRecord, "maxRecord", {"Timestamp", "Status"}, {"Timestamp", "Status"}),
    remOthCols = Table.SelectColumns(expandMaxRecord,{"ID", "Timestamp", "Status"})
in
    remOthCols

 

Example query output:

BA_Pete_0-1665657685389.png

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

1 REPLY 1
BA_Pete
Super User
Super User

Hi @youngmasterRD ,

 

You need to group your raw table on [ID] with the All Rows aggregator, then grab the row that features the MAX of [Timestamp].

 

Example query code:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjAwMFTSUTIsLlFwSU1OzU1KLVIwMjACifmllivF6sCVGOWlYCjxzNMNKMpPL0otLkZWalqSgaHUOT+3ICe1JDUFptAIh5lI1oKUGBcRsDYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Timestamp = _t, Status = _t]),
    chgTypes = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Timestamp", type text}, {"Status", type text}}),
    groupId = Table.Group(chgTypes, {"ID"}, {{"data", each _, type table [ID=nullable number, Timestamp=nullable text, Status=nullable text]}}),
    addMaxRecord = Table.AddColumn(groupId, "maxRecord", each Table.Max([data], "Timestamp")),
    expandMaxRecord = Table.ExpandRecordColumn(addMaxRecord, "maxRecord", {"Timestamp", "Status"}, {"Timestamp", "Status"}),
    remOthCols = Table.SelectColumns(expandMaxRecord,{"ID", "Timestamp", "Status"})
in
    remOthCols

 

Example query output:

BA_Pete_0-1665657685389.png

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.