Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
francescolar
Frequent Visitor

How to check if row of time ranges overlap with other rows (and multiple condition)

Hi everyone!

I'm new to Power BI!
I'm trying to create a "binary" column that should set the value 1 if two conditions are present simultaneously: the period is overlapped to others in the table (ex. row 1 and 6) and the production period in that row is longer.

As an example of my data.

 

MachineryDateStart_prodEnd_prodMinuts_prodCheck Overlap
A01/02/201901/02/2019 08:0001/02/2019 09:10701
A01/02/201901/02/2019 09:0001/02/2019 09:10100
B01/02/201901/02/2019 08:0001/02/2019 12:002400
B01/02/201901/02/2019 13:0001/02/2019 14:00600
A01/02/201901/02/2019 12:0001/02/2019 13:00600
A02/02/201902/02/2019 08:0002/02/2019 09:10701
A02/02/201902/02/2019 08:3002/02/2019 09:10400


Can you help me please? Thanks in advance!

1 ACCEPTED SOLUTION
francescolar
Frequent Visitor

Autofind solution 🙂

 

Period Overlap =
      VAR Overlapped =
              COUNTROWS(
                      FILTER(
                               ALL(Table);
                               Table[Start_prod] <= EARLIER(Table[Start_prod]) &&
                               Table[End_prod] >= EARLIER(Table[End_prod]) &&
                               Table[Date] = EARLIER(Table[Date]) &&
                               Table[Machinery] = EARLIER(Table[Machinery]) &&
                               Table[Id] <> EARLIER(Table[Id])
                               )
                    )
RETURN
IF(Overlapped; "YES"; "NO")

View solution in original post

1 REPLY 1
francescolar
Frequent Visitor

Autofind solution 🙂

 

Period Overlap =
      VAR Overlapped =
              COUNTROWS(
                      FILTER(
                               ALL(Table);
                               Table[Start_prod] <= EARLIER(Table[Start_prod]) &&
                               Table[End_prod] >= EARLIER(Table[End_prod]) &&
                               Table[Date] = EARLIER(Table[Date]) &&
                               Table[Machinery] = EARLIER(Table[Machinery]) &&
                               Table[Id] <> EARLIER(Table[Id])
                               )
                    )
RETURN
IF(Overlapped; "YES"; "NO")

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.