Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi!
I am trying to detect if a data set is consistent occurrences or has breaks.
For example, let's say I have a list of types (Q1-Q4) and the times that they occur.
See below:
I want to summarize a table that will look at each type (Q1-Q4) and return a column for day, hour, minute (and eventually second). Each column will return either "consistent" or "break".
For example, Q1 has a duration of 3 minutes and has one occurrence each minute.
Q2, has a duration of ~3 hours, but there is no occurrence when the hour is 3 and it does not occur consistently every minute.
Q3, has a duration of ~5 days, but there is no occurrence when the day is 14, 15, or 16. Nor does it occur consistently every hour or minute.
Q4 has a duration of ~3 hours. It does not occur every minute, but it does occur every hour during its lifespan.
The result would be the table below.
Help very much appreciated!
Solved! Go to Solution.
This is not the full answer. But it provides an algorithm for finding the breaks
I added an idex, that is a critical step, as I use the index to "move up one"
Then I created some calculated columns to extract month, day, hour, minute from the date
Then for each type of value i wrote a calculated column that calculated whether it was the same, or incremented by one from the previous date. If not I marked it as a "break"
The comparisons take the "quarter" into account, so when the value in the quarter column changes the first line is never a break, as it has no "previous" line to compare itself with.
If you need help parsing the code let me know.
Help when you know. Ask when you don't!
Hi @Anonymous ,
Try this:
1. Add Index column in Power Query Editor.
2. Create columns.
Day = DAY('Table'[Time])Hour = HOUR('Table'[Time])Minute = MINUTE('Table'[Time])Day 1 =
VAR PreviousIndex = 'Table'[Index] - 1
VAR PreviousDay_ =
CALCULATE (
MAX ( 'Table'[Day] ),
FILTER ( ALLEXCEPT ( 'Table', 'Table'[Type] ), PreviousIndex = 'Table'[Index] )
)
RETURN
IF ( ISBLANK ( PreviousDay_ ), BLANK (), 'Table'[Day] - PreviousDay_ )Hour 1 =
VAR PreviousIndex = 'Table'[Index] - 1
VAR PreviousHour_ =
CALCULATE (
MAX ( 'Table'[Hour] ),
FILTER ( ALLEXCEPT ( 'Table', 'Table'[Type] ), PreviousIndex = 'Table'[Index] )
)
RETURN
IF ( ISBLANK ( PreviousHour_ ), BLANK (), 'Table'[Hour] - PreviousHour_ )Minute 1 =
VAR PreviousIndex = 'Table'[Index] - 1
VAR PreviousMinute_ =
CALCULATE (
MAX ( 'Table'[Minute] ),
FILTER ( ALLEXCEPT ( 'Table', 'Table'[Type] ), PreviousIndex = 'Table'[Index] )
)
RETURN
IF ( ISBLANK ( PreviousMinute_ ), BLANK (), 'Table'[Minute] - PreviousMinute_ )Day 2 =
VAR PreviousIndex = 'Table'[Index] - 1
VAR PreviousDay_ =
CALCULATE (
MAX ( 'Table'[Day 1] ),
FILTER ( ALLEXCEPT ( 'Table', 'Table'[Type] ), PreviousIndex = 'Table'[Index] )
)
RETURN
IF ( ISBLANK ( PreviousDay_ ), BLANK (), 'Table'[Day 1] - PreviousDay_ )Hour 2 =
VAR PreviousIndex = 'Table'[Index] - 1
VAR PreviousHour_ =
CALCULATE (
MAX ( 'Table'[Hour 1] ),
FILTER ( ALLEXCEPT ( 'Table', 'Table'[Type] ), PreviousIndex = 'Table'[Index] )
)
RETURN
IF ( ISBLANK ( PreviousHour_ ), BLANK (), 'Table'[Hour 1] - PreviousHour_ )Minute 2 =
VAR PreviousIndex = 'Table'[Index] - 1
VAR PreviousMinute_ =
CALCULATE (
MAX ( 'Table'[Minute 1] ),
FILTER ( ALLEXCEPT ( 'Table', 'Table'[Type] ), PreviousIndex = 'Table'[Index] )
)
RETURN
IF (
ISBLANK ( PreviousMinute_ ),
BLANK (),
'Table'[Minute 1] - PreviousMinute_
)3. Create measures.
Day Measure = IF ( SUM ( 'Table'[Day 2] ) = 0, "Consistent", "Break" )Hour Measure = IF(SUM('Table'[Hour 2])=0,"Consistent","Break")Minute Measure = IF(SUM('Table'[Minute 2])=0,"Consistent","Break")
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
Try this:
1. Add Index column in Power Query Editor.
2. Create columns.
Day = DAY('Table'[Time])Hour = HOUR('Table'[Time])Minute = MINUTE('Table'[Time])Day 1 =
VAR PreviousIndex = 'Table'[Index] - 1
VAR PreviousDay_ =
CALCULATE (
MAX ( 'Table'[Day] ),
FILTER ( ALLEXCEPT ( 'Table', 'Table'[Type] ), PreviousIndex = 'Table'[Index] )
)
RETURN
IF ( ISBLANK ( PreviousDay_ ), BLANK (), 'Table'[Day] - PreviousDay_ )Hour 1 =
VAR PreviousIndex = 'Table'[Index] - 1
VAR PreviousHour_ =
CALCULATE (
MAX ( 'Table'[Hour] ),
FILTER ( ALLEXCEPT ( 'Table', 'Table'[Type] ), PreviousIndex = 'Table'[Index] )
)
RETURN
IF ( ISBLANK ( PreviousHour_ ), BLANK (), 'Table'[Hour] - PreviousHour_ )Minute 1 =
VAR PreviousIndex = 'Table'[Index] - 1
VAR PreviousMinute_ =
CALCULATE (
MAX ( 'Table'[Minute] ),
FILTER ( ALLEXCEPT ( 'Table', 'Table'[Type] ), PreviousIndex = 'Table'[Index] )
)
RETURN
IF ( ISBLANK ( PreviousMinute_ ), BLANK (), 'Table'[Minute] - PreviousMinute_ )Day 2 =
VAR PreviousIndex = 'Table'[Index] - 1
VAR PreviousDay_ =
CALCULATE (
MAX ( 'Table'[Day 1] ),
FILTER ( ALLEXCEPT ( 'Table', 'Table'[Type] ), PreviousIndex = 'Table'[Index] )
)
RETURN
IF ( ISBLANK ( PreviousDay_ ), BLANK (), 'Table'[Day 1] - PreviousDay_ )Hour 2 =
VAR PreviousIndex = 'Table'[Index] - 1
VAR PreviousHour_ =
CALCULATE (
MAX ( 'Table'[Hour 1] ),
FILTER ( ALLEXCEPT ( 'Table', 'Table'[Type] ), PreviousIndex = 'Table'[Index] )
)
RETURN
IF ( ISBLANK ( PreviousHour_ ), BLANK (), 'Table'[Hour 1] - PreviousHour_ )Minute 2 =
VAR PreviousIndex = 'Table'[Index] - 1
VAR PreviousMinute_ =
CALCULATE (
MAX ( 'Table'[Minute 1] ),
FILTER ( ALLEXCEPT ( 'Table', 'Table'[Type] ), PreviousIndex = 'Table'[Index] )
)
RETURN
IF (
ISBLANK ( PreviousMinute_ ),
BLANK (),
'Table'[Minute 1] - PreviousMinute_
)3. Create measures.
Day Measure = IF ( SUM ( 'Table'[Day 2] ) = 0, "Consistent", "Break" )Hour Measure = IF(SUM('Table'[Hour 2])=0,"Consistent","Break")Minute Measure = IF(SUM('Table'[Minute 2])=0,"Consistent","Break")
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
could you supply a text version of the data table instead of a ping, or a small excel file.
Thanks
Help when you know. Ask when you don't!
This is not the full answer. But it provides an algorithm for finding the breaks
I added an idex, that is a critical step, as I use the index to "move up one"
Then I created some calculated columns to extract month, day, hour, minute from the date
Then for each type of value i wrote a calculated column that calculated whether it was the same, or incremented by one from the previous date. If not I marked it as a "break"
The comparisons take the "quarter" into account, so when the value in the quarter column changes the first line is never a break, as it has no "previous" line to compare itself with.
If you need help parsing the code let me know.
Help when you know. Ask when you don't!
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.