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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.