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
bryn987
Helper I
Helper I

Calculated Column - Datediff with multiple filters?

I have the following calculated column that works well but I'm having issues also trying to filter out weekends and holidays from a date table

 

Any ideas?

 

# Days since Updated = IF(OR(
'Cases'[State]="Open",
'Cases'[State]="Awaiting Info" ||
'Cases'[State]= "Work in Progress" ||
'Cases'[State]= "New"),
(Today()-'CS Cases'[Updated])

 

I would also like to filter out weekends and holidays using a date table and have these 2 fields

'Date'[Business_Day]=1
'Date'[Holiday_Flag]=0
3 REPLIES 3
jdbuchanan71
Super User
Super User

Can you share your .pbix file (load it to dropbox and post a link here)?  

jdbuchanan71
Super User
Super User

@bryn987 

Give something like this a try.  It counts the days between the start and end after taking out weekends and holidays.

 

# Days since Updated =
VAR _StartDate = 'CS Cases'[Updated]
VAR _EndDate = TODAY ()
RETURN
    IF ('Cases'[State] IN { "Open", "Awaiting Info", "Work in Progress", "New" },
        CALCULATE (
            COUNTROWS ( Date ),
            DATESBETWEEN ( Date[Date], _StartDate, _EndDate ),
            'Date'[Business_Day] = 1 && 'Date'[Holiday_Flag] = 0
        ) - 1
    )

 

You would add this as your calculated column.

Thank you but now I'm getting an invalid numberic representation of a date value was encounted 

 

Any ideas?

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.