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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Jigar1276
Helper I
Helper I

Add custom column by finding the latest date for each "key" column

Hi,

 

I want to add one column to following table where I can get flag about latest "Status Change Date" for each "key".

For bellow screenshot, I want "Yes" for key "st-273" for blue highlated date row. Simillary for key "st-272" lastest date is yellow highlated row.

Screenshot 2021-07-05 195447.jpg

Thanks in advance for any help in this regards.

1 ACCEPTED SOLUTION
Jakinta
Solution Sage
Solution Sage

Hope this can help.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bc4xCoAwEETRq8jWgcmsCXHt9Boh97+GhlTiwFSvGH7vdlmywA7nls88ZyMtbuChnHDpFe7KCxjKXfi9/Pc/nURR/sY35YH64fEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [key = _t, #"Status Change Date" = _t]),
    ChangedType = Table.TransformColumnTypes(Source,{{"Status Change Date", type datetime}}),
    GroupedRows = Table.Group(ChangedType, {"key"}, {{"MaxDate", each List.Max([Status Change Date]), type nullable datetime}}),
    #"Added Custom" = Table.AddColumn(ChangedType, "Custom", each if let k=[key] in [Status Change Date] = Table.SelectRows(GroupedRows, each ([key]=k )){0}[MaxDate] then "Yes" else "")
in
    #"Added Custom"

View solution in original post

2 REPLIES 2
Jakinta
Solution Sage
Solution Sage

Hope this can help.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bc4xCoAwEETRq8jWgcmsCXHt9Boh97+GhlTiwFSvGH7vdlmywA7nls88ZyMtbuChnHDpFe7KCxjKXfi9/Pc/nURR/sY35YH64fEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [key = _t, #"Status Change Date" = _t]),
    ChangedType = Table.TransformColumnTypes(Source,{{"Status Change Date", type datetime}}),
    GroupedRows = Table.Group(ChangedType, {"key"}, {{"MaxDate", each List.Max([Status Change Date]), type nullable datetime}}),
    #"Added Custom" = Table.AddColumn(ChangedType, "Custom", each if let k=[key] in [Status Change Date] = Table.SelectRows(GroupedRows, each ([key]=k )){0}[MaxDate] then "Yes" else "")
in
    #"Added Custom"

@Jakinta This is perfect. Thanks a lot for this. 👍

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors
Top Kudoed Authors