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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Anonymous
Not applicable

Calculated column showing number of overlapping dates with same material #

Dustin02_0-1639153628253.png

Im trying to write Dax formula that gives the number of overlapping time periods for that row with the other rows with the same material #

 

1 ACCEPTED SOLUTION
PaulOlding
Solution Sage
Solution Sage

Hi @Anonymous 

 

You have one line on your data where the end date is before the start date.  I've assumed that's a typo in this solution.  If that is something that can occur the CALENDAR function will cause an error

Overlaps = 
VAR _calendar = CALENDAR('Table'[start date], 'Table'[end date])
VAR _material = 'Table'[Material #]
RETURN
COUNTROWS(
    FILTER('Table', 
        'Table'[Material #] = _material
        && COUNTROWS(INTERSECT(CALENDAR('Table'[start date], 'Table'[end date]), _calendar)) > 0
        )
    ) - 1

 

 

View solution in original post

2 REPLIES 2
PaulOlding
Solution Sage
Solution Sage

Hi @Anonymous 

 

You have one line on your data where the end date is before the start date.  I've assumed that's a typo in this solution.  If that is something that can occur the CALENDAR function will cause an error

Overlaps = 
VAR _calendar = CALENDAR('Table'[start date], 'Table'[end date])
VAR _material = 'Table'[Material #]
RETURN
COUNTROWS(
    FILTER('Table', 
        'Table'[Material #] = _material
        && COUNTROWS(INTERSECT(CALENDAR('Table'[start date], 'Table'[end date]), _calendar)) > 0
        )
    ) - 1

 

 

Anonymous
Not applicable

can you modify this so it return the maxium over lap by day over the time interval. 

Dustin02_0-1639424600600.png

 

i want the column to show the most number by row material number it over laps with on a single day. Not the whole start to end date.

Dustin02_1-1639424811519.png

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

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