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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Kavya123
Helper III
Helper III

Latest data using Group by

Hi All,

 

I need to have a new desc column based on  the latest data. 

For ex: If ID is 1363 then new Desc is CC ( Max date 1/20/2021 9:11:12 PM)

 

Please help me to achieve this.  Please find the sample data and resultant output.

 

image.png

 

 

1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

Hi @Kavya123 ,

 

Please try this:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQ2M1bSUXJ0dASSRgZGBrqWusYGSrE6cCknJyeIlKEuEFoiSzk7I2SMUDS5uLjAzLPQNTJDlnJzc8NlnqurK6qBsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [id = _t, Desc = _t, Date = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"id", Int64.Type}, {"Desc", type text}, {"Date", type date}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"id"}, {{"Max", each List.Max([Date]), type nullable date}, {"S", each _, type table [id=nullable number, Desc=nullable text, Date=nullable date]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.SelectRows(
     [S],
     (itable) => itable[Date]=[Max])),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"Desc"}, {"Desc"}),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded Custom",{"S"})
in
    #"Removed Columns"

V-lianl-msft_0-1615959206017.png

 

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
V-lianl-msft
Community Support
Community Support

Hi @Kavya123 ,

 

Please try this:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQ2M1bSUXJ0dASSRgZGBrqWusYGSrE6cCknJyeIlKEuEFoiSzk7I2SMUDS5uLjAzLPQNTJDlnJzc8NlnqurK6qBsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [id = _t, Desc = _t, Date = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"id", Int64.Type}, {"Desc", type text}, {"Date", type date}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"id"}, {{"Max", each List.Max([Date]), type nullable date}, {"S", each _, type table [id=nullable number, Desc=nullable text, Date=nullable date]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.SelectRows(
     [S],
     (itable) => itable[Date]=[Max])),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"Desc"}, {"Desc"}),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded Custom",{"S"})
in
    #"Removed Columns"

V-lianl-msft_0-1615959206017.png

 

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks for your reply. I got the solution

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.