Forum Discussion
Start a counter when an instance occurs, when it ends then save that and start a new one
- 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
could you pls provide some sample data and expected output? (not the screenshot).
This would be an example of what I'm working with
| Time | Line 13 Current Read {} | Line 13 Last Minute Total {} |
| 2026-03-06T06:00:00 | 0 | 3 |
| 2026-03-06T06:01:00 | 0 | 3 |
| 2026-03-06T06:02:00 | 0 | 0 |
| 2026-03-06T06:03:00 | 0 | 0 |
| 2026-03-06T06:04:00 | 1 | 0 |
| 2026-03-06T06:05:00 | 3 | 1 |
| 2026-03-06T06:06:00 | 0 | 3 |
| 2026-03-06T06:07:00 | 0 | 0 |
| 2026-03-06T06:08:00 | 0 | 0 |
| 2026-03-06T06:09:00 | 0 | 0 |
| 2026-03-06T06:10:00 | 3 | 0 |
| 2026-03-06T06:11:00 | 3 | 3 |
| 2026-03-06T06:12:00 | 4 | 3 |
| 2026-03-06T06:13:00 | 3 | 4 |
| 2026-03-06T06:14:00 | 5 | 3 |
| 2026-03-06T06:15:00 | 1 | 8 |
| 2026-03-06T06:16:00 | 4 | 8 |
| 2026-03-06T06:17:00 | 0 | 4 |
| 2026-03-06T06:18:00 | 4 | 0 |
| 2026-03-06T06:19:00 | 4 | 4 |
| 2026-03-06T06:20:00 | 7 | 5 |
| 2026-03-06T06:21:00 | 7 | 7 |
| 2026-03-06T06:22:00 | 7 | 7 |
| 2026-03-06T06:23:00 | 0 | 7 |
| 2026-03-06T06:24:00 | 3 | 0 |
| 2026-03-06T06:25:00 | 8 | 3 |
| 2026-03-06T06:26:00 | 7 | 8 |
| 2026-03-06T06:27:00 | 6 | 7 |
| 2026-03-06T06:28:00 | 7 | 6 |
| 2026-03-06T06:29:00 | 8 | 7 |
| 2026-03-06T06:30:00 | 0 | 8 |
| 2026-03-06T06:31:00 | 7 | 8 |
| 2026-03-06T06:32:00 | 7 | 7 |
| 2026-03-06T06:33:00 | 1 | 7 |
| 2026-03-06T06:34:00 | 7 | 1 |
| 2026-03-06T06:35:00 | 4 | 7 |
| 2026-03-06T06:36:00 | 0 | 4 |
| 2026-03-06T06:37:00 | 3 | 0 |
| 2026-03-06T06:38:00 | 5 | 3 |
| 2026-03-06T06:39:00 | 7 | 5 |
| 2026-03-06T06:40:00 | 0 | 7 |
| 2026-03-06T06:41:00 | 1 | 0 |
| 2026-03-06T06:42:00 | 6 | 1 |
| 2026-03-06T06:43:00 | 3 | 6 |
| 2026-03-06T06:44:00 | 2 | 3 |
| 2026-03-06T06:45:00 | 1 | 7 |
| 2026-03-06T06:46:00 | 4 | 7 |
| 2026-03-06T06:47:00 | 0 | 4 |
| 2026-03-06T06:48:00 | 0 | 0 |
| 2026-03-06T06:49:00 | 0 | 0 |
| 2026-03-06T06:50:00 | 0 | 0 |
| 2026-03-06T06:51:00 | 0 | 0 |
| 2026-03-06T06:52:00 | 0 | 0 |
| 2026-03-06T06:53:00 | 5 | 0 |
| 2026-03-06T06:54:00 | 6 | 5 |
| 2026-03-06T06:55:00 | 4 | 6 |
| 2026-03-06T06:56:00 | 1 | 4 |
| 2026-03-06T06:57:00 | 2 | 1 |
| 2026-03-06T06:58:00 | 0 | 2 |
| 2026-03-06T06:59:00 | 0 | 0 |
| 2026-03-06T07:00:00 | 0 | 0 |
- danextian7 months ago
Super User
Are the line columns your expected result? If not, please show and provide the logic why. If yes, please also provide the logic why those are the numbers.
- Tugwell7 months agoFrequent Visitor
There is only a single line, line 13, in this sample as I couldn't post several with a good scope of data.
Each number is how many cycles per minute that line has run. If the cycle is 0, that's 1 minute of downtime.
I need to do this for 10 lines. If the line stops for X amount of minutes, I want to know the start time of that stop, and the end time of that stop. There may be a need in future to isolate to stops that are longer than 5 minutes hence why I'm saying X amount of minutes.
This is a sample of the raw data
- danextian7 months ago
Super User
In you first post:
have made made any row showing a 0 is counted as 1. 0 means there's no cycles.
However in your sample data, there are rows that is neither 1 or 0.