cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bryn987
Frequent Visitor

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
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors