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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Pbiuserr
Post Prodigy
Post Prodigy

Please help with formula to add another argument

Hello,

I perform such action - Ive managed to group ID by max date

 

 

 

#"Grouped Rows" = Table.Group(#"Previous Step", {"ID"}, {{"NewTbl", each let t =_ in Table.SelectRows(t, each [CREATION DATE] = List.Max(t[CREATION DATE])), type table }})
))

 

 

 

However my criteria are - max date for ID, and if date is the same, then max value for the date. If it happens that date and value is the same for all lines for certain ID - just take one line for that ID 

 

It suppose to look like this

 

My initial table

IDCREATION DATEVALUE
ID101.01.2022100
ID101.01.2022150
ID101.02.2022100
ID201.03.2022150
ID201.03.2022100
ID301.04.2022300
ID301.04.2022300
ID301.04.2022300

 

Expected output

IDCREATION DATEVALUE
ID101.02.2022100
ID201.03.2022150
ID301.04.2022300

 

Thank you in advance for your help

1 ACCEPTED SOLUTION
Vijay_A_Verma
Super User
Super User

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8nQxVNJRMjIwMtI1MAQiIMfQwEApVge7lCmmlBG6LiO4lDG6LkwpuC5juJQJRMqYfKlYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, #"CREATION DATE" = _t, VALUE = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", type text}, {"CREATION DATE", type date}, {"VALUE", Int64.Type}}),
    #"Grouped Rows1" = Table.Group(#"Changed Type", {"ID", "CREATION DATE"}, {{"VALUE", each List.Max([VALUE]), type nullable number}}),
    #"Grouped Rows" = Table.Group(#"Grouped Rows1", {"ID"}, {{"MaxDate", each List.Max([CREATION DATE]), type nullable date}}),
    #"Merged Queries" = Table.NestedJoin(#"Grouped Rows", {"ID", "MaxDate"}, #"Grouped Rows1", {"ID", "CREATION DATE"}, "Grouped Rows", JoinKind.LeftOuter),
    #"Expanded Grouped Rows" = Table.ExpandTableColumn(#"Merged Queries", "Grouped Rows", {"VALUE"}, {"VALUE"})
in
    #"Expanded Grouped Rows"

 

View solution in original post

3 REPLIES 3
Vijay_A_Verma
Super User
Super User

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8nQxVNJRMjIwMtI1MAQiIMfQwEApVge7lCmmlBG6LiO4lDG6LkwpuC5juJQJRMqYfKlYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, #"CREATION DATE" = _t, VALUE = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", type text}, {"CREATION DATE", type date}, {"VALUE", Int64.Type}}),
    #"Grouped Rows1" = Table.Group(#"Changed Type", {"ID", "CREATION DATE"}, {{"VALUE", each List.Max([VALUE]), type nullable number}}),
    #"Grouped Rows" = Table.Group(#"Grouped Rows1", {"ID"}, {{"MaxDate", each List.Max([CREATION DATE]), type nullable date}}),
    #"Merged Queries" = Table.NestedJoin(#"Grouped Rows", {"ID", "MaxDate"}, #"Grouped Rows1", {"ID", "CREATION DATE"}, "Grouped Rows", JoinKind.LeftOuter),
    #"Expanded Grouped Rows" = Table.ExpandTableColumn(#"Merged Queries", "Grouped Rows", {"VALUE"}, {"VALUE"})
in
    #"Expanded Grouped Rows"

 

Hi,

It works! May I ask how come you merged table? With which table? I can see that with previous one but, you did that by typing, not using ribbon options and clicking right? Because I tried to replicate that and I couldnt select previous table (with no maxdate just CREATION DATE)

Yes, first you will have to do a self merge i.e same table to same table. Then you will need to change one part manually. 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.