Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by watching the DP-600 session on-demand now through April 28th.
Learn moreJoin 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
hey,
i log a machine state as soon it changes:
from this i would like to calculate how long the machine is in each state.
So the output should look like this:
Also it would be cool if I could show the machine state visually over time.
Thanks in advance.
Regards,
Luis
Solved! Go to Solution.
Hi,
open Power Query Editor and following the steps:
// Table
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrDQMzDSMzIwMlAwNLYyMFDIz1OK1UEXB5K5iXmliTkYciZWxlj1mFoZGimkFhXlF2FImVkZGGLTAhQ3RbHGEtkaJKdZolmPQ48pstMske1BdRqKFC4tJginxQIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
#"Split Column by Delimiter" = Table.SplitColumn(Source, "Column1", Splitter.SplitTextByDelimiter(" ", QuoteStyle.Csv), {"Column1.1", "Column1.2", "Column1.3"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Column1.1", type date}, {"Column1.2", type time}, {"Column1.3", type text}}),
#"Renamed Columns" = Table.RenameColumns(#"Changed Type1",{{"Column1.1", "Date"}, {"Column1.2", "Time"}, {"Column1.3", "Status"}}),
#"Sorted Rows" = Table.Sort(#"Renamed Columns",{{"Date", Order.Ascending}, {"Time", Order.Ascending}}),
#"Added Index" = Table.AddIndexColumn(#"Sorted Rows", "Index", 1, 1),
#"Added Index1" = Table.AddIndexColumn(#"Added Index", "Index.1", 0, 1),
#"Grouped Rows" = Table.Group(#"Added Index1", {"Date"}, {{"Group", each _, type table [Date=date, Time=time, Status=text, Index=number, Index.1=number]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.NestedJoin([Group], {"Index"}, [Group], {"Index.1"}, "Table", JoinKind.LeftOuter)),
#"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"Custom"}),
#"Expanded Custom" = Table.ExpandTableColumn(#"Removed Other Columns", "Custom", {"Date", "Time", "Status", "Index", "Index.1", "Table"}, {"Date", "Time", "Status", "Index", "Index.1", "Table"}),
#"Expanded Table" = Table.ExpandTableColumn(#"Expanded Custom", "Table", {"Time"}, {"Time.1"}),
#"Inserted Time Subtraction" = Table.AddColumn(#"Expanded Table", "Subtraction", each [Time.1] - [Time], type duration),
#"Grouped Rows1" = Table.Group(#"Inserted Time Subtraction", {"Date", "Status"}, {{"Count", each List.Sum([Subtraction]), type duration}}),
#"Changed Type" = Table.TransformColumnTypes(#"Grouped Rows1",{{"Date", type date}, {"Status", type text}})
in
#"Changed Type"
REgards FrankAT
Hi,
open Power Query Editor and following the steps:
// Table
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrDQMzDSMzIwMlAwNLYyMFDIz1OK1UEXB5K5iXmliTkYciZWxlj1mFoZGimkFhXlF2FImVkZGGLTAhQ3RbHGEtkaJKdZolmPQ48pstMske1BdRqKFC4tJginxQIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
#"Split Column by Delimiter" = Table.SplitColumn(Source, "Column1", Splitter.SplitTextByDelimiter(" ", QuoteStyle.Csv), {"Column1.1", "Column1.2", "Column1.3"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Column1.1", type date}, {"Column1.2", type time}, {"Column1.3", type text}}),
#"Renamed Columns" = Table.RenameColumns(#"Changed Type1",{{"Column1.1", "Date"}, {"Column1.2", "Time"}, {"Column1.3", "Status"}}),
#"Sorted Rows" = Table.Sort(#"Renamed Columns",{{"Date", Order.Ascending}, {"Time", Order.Ascending}}),
#"Added Index" = Table.AddIndexColumn(#"Sorted Rows", "Index", 1, 1),
#"Added Index1" = Table.AddIndexColumn(#"Added Index", "Index.1", 0, 1),
#"Grouped Rows" = Table.Group(#"Added Index1", {"Date"}, {{"Group", each _, type table [Date=date, Time=time, Status=text, Index=number, Index.1=number]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.NestedJoin([Group], {"Index"}, [Group], {"Index.1"}, "Table", JoinKind.LeftOuter)),
#"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"Custom"}),
#"Expanded Custom" = Table.ExpandTableColumn(#"Removed Other Columns", "Custom", {"Date", "Time", "Status", "Index", "Index.1", "Table"}, {"Date", "Time", "Status", "Index", "Index.1", "Table"}),
#"Expanded Table" = Table.ExpandTableColumn(#"Expanded Custom", "Table", {"Time"}, {"Time.1"}),
#"Inserted Time Subtraction" = Table.AddColumn(#"Expanded Table", "Subtraction", each [Time.1] - [Time], type duration),
#"Grouped Rows1" = Table.Group(#"Inserted Time Subtraction", {"Date", "Status"}, {{"Count", each List.Sum([Subtraction]), type duration}}),
#"Changed Type" = Table.TransformColumnTypes(#"Grouped Rows1",{{"Date", type date}, {"Status", type text}})
in
#"Changed Type"
REgards FrankAT
See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395...
Check out the April 2026 Power BI update to learn about new features.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 41 | |
| 37 | |
| 34 | |
| 21 | |
| 16 |
| User | Count |
|---|---|
| 64 | |
| 58 | |
| 31 | |
| 25 | |
| 25 |