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!View all the Fabric Data Days sessions on demand. View schedule
Hi all,
I'm stuck for a while on this situation:
See here a sample off my data:
I have for all employees a column with the timestamp when they logged in or logged out.
Now i want to create a 3rdcustomn column with an "online" status.
So in this example i should see "Online" for each row between 20:18:36 and 04:59:11. Before and after that period it should be filled with "offline".
The formula should look for the previous rows till it's not blanc. If it is not blank is should report "online" when text "Logging in" is found and "Offline" when "Logged off" is found. I added an index column but also no luck with that.
Anyone suggestions?
Thanks in advace.
Solved! Go to Solution.
Hi @baekelal ,
Please open a blank query and paste the code.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("lZHBCsIwEER/JeRc6GaThdajR/EPSg9K2hAozcn/twhWSTNBDzm9zOzuzDBopZvXsy11LROzMv2JSI8NYBYxprfuclvios7pcZ+8j9unawohrkHFNVeYDrvhSQZvuLFM53ZmMXK54zeylbMmr9I8ZwLpgZfgMYKX+yRbZLX19tRLioLbIVn3U7LMFR1XdIdKBLcluC35ty3BbUnW1vgE", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [NAME = _t, Action = _t, Tijdstip = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"NAME", type text}, {"Action", type text}, {"Tijdstip", type datetime}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Status", each if [Action] = "Logging in" then "Online" else if [Action] = "Logged off" then "Offline" else null),
#"Filled Down" = Table.FillDown(#"Added Custom",{"Status"}),
#"Transform Columns" = Table.TransformColumns( #"Filled Down", {{"Status", each if _ = null then "Offline" else _, type text}
})
in
#"Transform Columns"
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi All,
I searched a bit more myself and found a solution. This is what i came up with:
Hi All,
I searched a bit more myself and found a solution. This is what i came up with:
In Power Query, First replace blank cells of Log-In/Log-Off column with null.
Then do Fill Down, either from Transform menu or right click on column.
Replace Log-In value with Online and Log-Off and null values with Offline.
Voila, You got what you want.
Hi,
this is not what i want. It depends on the last action off that person what follows. I made a better view off what i want:
| NAME | Action | Tijdstip | Status |
| 3/08/2022 19:00 | Offline | ||
| 3/08/2022 19:30 | Offline | ||
| 3/08/2022 20:00 | Offline | ||
| Jalil Boubeddi | Logging in | 3/08/2022 20:18 | Online |
| 3/08/2022 20:30 | Online | ||
| 3/08/2022 21:00 | Online | ||
| 3/08/2022 21:30 | Online | ||
| 4/08/2022 3:30 | Online | ||
| 4/08/2022 4:00 | Online | ||
| 4/08/2022 4:30 | Online | ||
| Jalil Boubeddi | Logged off | 4/08/2022 4:59 | Offline |
| 4/08/2022 5:00 | Offline | ||
| 4/08/2022 5:30 | Offline | ||
| 4/08/2022 20:00 | Offline | ||
| 4/08/2022 20:30 | Offline | ||
| Jalil Boubeddi | Logging in | 4/08/2022 20:30 | Online |
| 4/08/2022 21:00 | Online | ||
| 4/08/2022 21:30 | Online | ||
| 4/08/2022 22:00 | Online | ||
| 4/08/2022 22:30 | Online | ||
| 4/08/2022 23:30 | Online | ||
| 5/08/2022 3:30 | Online | ||
| 5/08/2022 4:00 | Online | ||
| 5/08/2022 4:30 | Online | ||
| Jalil Boubeddi | Logged off | 5/08/2022 4:59 | Offline |
| 5/08/2022 5:00 | Offline |
The column "Status" should be calculated on the column "Action":
- If column Action = "Logging in" status should be "Online"
- If column Action = "Logged off" status should be "Offline
- If column Action = blanc then te previous last action should remain.
See the example.
Any help is welcome.
Hi @baekelal ,
Please open a blank query and paste the code.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("lZHBCsIwEER/JeRc6GaThdajR/EPSg9K2hAozcn/twhWSTNBDzm9zOzuzDBopZvXsy11LROzMv2JSI8NYBYxprfuclvios7pcZ+8j9unawohrkHFNVeYDrvhSQZvuLFM53ZmMXK54zeylbMmr9I8ZwLpgZfgMYKX+yRbZLX19tRLioLbIVn3U7LMFR1XdIdKBLcluC35ty3BbUnW1vgE", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [NAME = _t, Action = _t, Tijdstip = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"NAME", type text}, {"Action", type text}, {"Tijdstip", type datetime}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Status", each if [Action] = "Logging in" then "Online" else if [Action] = "Logged off" then "Offline" else null),
#"Filled Down" = Table.FillDown(#"Added Custom",{"Status"}),
#"Transform Columns" = Table.TransformColumns( #"Filled Down", {{"Status", each if _ = null then "Offline" else _, type text}
})
in
#"Transform Columns"
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!