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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
powerplatp0
New Member

Power Query - get data from another column based on date

Hello all, 

 

I have a business problem that requires a solution similar to (Solved: Power Query - Get data from another table if condi... - Microsoft Fabric Community) question however I haven't been able to implement after working on this all day. 

 

I have the following aggregated table:

IDLocationDateStatus
1Miami 06/01/2024Complete
2Miami02/01/2024Incomplete 
3Tampa11/11/2024Complete 
4Orlando 07/10/2025TBD
5Orlando05/03/2025Complete
6Orlando05/01/2025Complete
7Melbourne09/25/2022Incomplete 

 

The table is already sorted so that the first entry of row of a common Location is the latest Date. I want create a new column that returns the Status of the most recent Date for every Location. The other Date rows should be null. The result table should look like: 

 

IDLocationDateStatusNew
1Miami 06/01/2024Complete

Complete

2Miami02/01/2024Incomplete null
3Tampa11/11/2024Complete Complete
4Orlando 07/10/2025TBDTBD
5Orlando05/03/2025Complete

null

6Orlando05/01/2025Completenull
7Melbourne09/25/2022Incomplete Incomplete

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @powerplatp0 

 

You can try the following methods.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUfLNTMzNBNJm+ob6RgZGJkCmc35uQU5qSapSrE60khGSGiOEGs+8ZKgqBbAyY6BYSGJuQSKQNjTUN8QwDKIMJOJflJOYl5IPZJnrGxqA1JmCNDu5gFWYoqgw1TeGKUBxlRmaKkOsqsxBbk/NScovLcpLBbIt9Y1MQQqNUDygFBsLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Location = _t, Date = _t, Status = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Location", type text}, {"Date", type date}, {"Status", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Location"}, {{"Data", each _}}),
    Custom1 = Table.TransformColumns(#"Grouped Rows",{"Data", each Table.FirstN(_,1)}),
    #"Expanded Data" = Table.ExpandTableColumn(Custom1, "Data", {"ID", "Status"}, {"Data.ID", "Data.Status"}),
    #"Merged Queries" = Table.NestedJoin(#"Changed Type", {"ID"}, #"Expanded Data", {"Data.ID"}, "Expanded Data", JoinKind.LeftOuter),
    #"Expanded Expanded Data" = Table.ExpandTableColumn(#"Merged Queries", "Expanded Data", {"Data.Status"}, {"Data.Status"})
in
    #"Expanded Expanded Data"

vzhangtinmsft_0-1740124863297.png

Is this the result you expected?

 

Best Regards,

Community Support Team _Charlotte

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
Anonymous
Not applicable

Hi, @powerplatp0 

 

You can try the following methods.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUfLNTMzNBNJm+ob6RgZGJkCmc35uQU5qSapSrE60khGSGiOEGs+8ZKgqBbAyY6BYSGJuQSKQNjTUN8QwDKIMJOJflJOYl5IPZJnrGxqA1JmCNDu5gFWYoqgw1TeGKUBxlRmaKkOsqsxBbk/NScovLcpLBbIt9Y1MQQqNUDygFBsLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Location = _t, Date = _t, Status = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Location", type text}, {"Date", type date}, {"Status", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Location"}, {{"Data", each _}}),
    Custom1 = Table.TransformColumns(#"Grouped Rows",{"Data", each Table.FirstN(_,1)}),
    #"Expanded Data" = Table.ExpandTableColumn(Custom1, "Data", {"ID", "Status"}, {"Data.ID", "Data.Status"}),
    #"Merged Queries" = Table.NestedJoin(#"Changed Type", {"ID"}, #"Expanded Data", {"Data.ID"}, "Expanded Data", JoinKind.LeftOuter),
    #"Expanded Expanded Data" = Table.ExpandTableColumn(#"Merged Queries", "Expanded Data", {"Data.Status"}, {"Data.Status"})
in
    #"Expanded Expanded Data"

vzhangtinmsft_0-1740124863297.png

Is this the result you expected?

 

Best Regards,

Community Support Team _Charlotte

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

Irwan
Super User
Super User

hello @powerplatp0 

 

please check if this accomodate your need.

Irwan_0-1740100306287.png

 

create new calculated column with following DAX.

New =
var _MaxDate =
MAXX(
    FILTER(
        'Table',
        'Table'[Location]=EARLIER('Table'[Location])
    ),
    'Table'[Date]
)
Return
IF(
    'Table'[Date]=_MaxDate,
    'Table'[Status],
    "Null"
)
 
Hope this will help.
Thank you.

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

FabCon and SQLCon Highlights Carousel

FabCon & SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.