Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!
Hello everybody.
Table A (ID, timestamp, status) has these entries:
Table B (ID, timestamp, status) has these entries:
Output:
Requirements:
Solved! Go to Solution.
Hi @NewPBIe ,
I think you can try Merge function (Left Outer Table A by [ID]) in Power Query Editor.
For reference: Merge queries overview - Power Query | Microsoft Learn
Then create custom columns by M Query and do some filter.
let
Source = Table.NestedJoin(#"Table A", {"ID"}, #"Table B", {"ID"}, "Table B", JoinKind.LeftOuter),
#"Expanded Table B" = Table.ExpandTableColumn(Source, "Table B", {"timestamp", "status"}, {"timestamp.1", "status.1"}),
#"Added Custom" = Table.AddColumn(#"Expanded Table B", "timestamp B", each if [timestamp.1] = null then DateTime.LocalNow()
else if [timestamp.1] > [timestamp] then [timestamp.1]
else null),
#"Filtered Rows" = Table.SelectRows(#"Added Custom", each [timestamp B] <> null and [timestamp B] <> ""),
#"Added Custom1" = Table.AddColumn(#"Filtered Rows", "status B", each "UP"),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"timestamp.1", "status.1"})
in
#"Removed Columns"
Result is as below.
You can download my sample file to learn more details.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
As I understand this, it might be difficult to do in Power Query as you need to do some JOINs, but not alwasy EQUALTIY joins.
What is your source system? Can you write a query at that level? How good are you with T-SQL?
Proud to be a Super User! | |
exactly, it would be a "join" with the MIN of all the TableB[timestamp] that are bigger than TableA[timestamp].
My source id a unique csv file with all downs and ups together.
Unfortunately no T-SQL Skills- only study level SQL
Hi @NewPBIe ,
I think you can try Merge function (Left Outer Table A by [ID]) in Power Query Editor.
For reference: Merge queries overview - Power Query | Microsoft Learn
Then create custom columns by M Query and do some filter.
let
Source = Table.NestedJoin(#"Table A", {"ID"}, #"Table B", {"ID"}, "Table B", JoinKind.LeftOuter),
#"Expanded Table B" = Table.ExpandTableColumn(Source, "Table B", {"timestamp", "status"}, {"timestamp.1", "status.1"}),
#"Added Custom" = Table.AddColumn(#"Expanded Table B", "timestamp B", each if [timestamp.1] = null then DateTime.LocalNow()
else if [timestamp.1] > [timestamp] then [timestamp.1]
else null),
#"Filtered Rows" = Table.SelectRows(#"Added Custom", each [timestamp B] <> null and [timestamp B] <> ""),
#"Added Custom1" = Table.AddColumn(#"Filtered Rows", "status B", each "UP"),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"timestamp.1", "status.1"})
in
#"Removed Columns"
Result is as below.
You can download my sample file to learn more details.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
| User | Count |
|---|---|
| 53 | |
| 40 | |
| 35 | |
| 24 | |
| 22 |
| User | Count |
|---|---|
| 134 | |
| 107 | |
| 57 | |
| 43 | |
| 38 |