Forum Discussion

Tugwell's avatar
Tugwell
Frequent Visitor
7 months ago
Solved

Start a counter when an instance occurs, when it ends then save that and start a new one

Sorry for the messy title, but I'll list what I'm trying to do and it may make more sense.   I have a table as shown below.  I have added the "DT" lines to indicate 1 minute of downtime.   ...
  • Tugwell's avatar
    7 months ago

    Thanks all for the help.  In the end I've had to use an amalgamation of solutions and came up with this.

     

    I used a group by to group each row of data, then changed to GroupKind.Local to show each instance of the occurance

    = Table.Group(#"Removed Columns8", {"Line 4 Status"}, {{"Details 8", each _, type table [Index=number, Date=date, Time=time, Line 4=number, Line 4 Status=number, Line 7=number, Line 7 Status.1=number, Line 8=number, Line 8 Status.1=number, Line 9=number, Line 9 Status.1=number, Line 12=number, Line 12 Status.1=number, Line 13=number, Line 13 Status.1=number, Line 14=number, Line 14 Status.1=number, Line 15=number, Line 15 Status.1=number, Line 18=number, Line 18 Status.1=number, #"Time - Copy"=datetime, Consecutive Count 13=number, Consecutive Count 18=number, Consecutive Count 15.1=number, Consecutive Count 14=number, Consecutive Count 12=number, Consecutive Count 9=number, Consecutive Count 8=number, Consecutive Count 7=number]}},GroupKind.Local)

    Then added a custom column per line to count consecutively

    = Table.AddColumn(#"Grouped Rows8", "Custom", each if [Line 4 Status] = 1
    then Table.AddIndexColumn([Details 8], "Consecutive Count 4", 1, 1)
    else Table.AddColumn([Details 8],"Consecutive Count 4",  each 0))

    This gave me this result