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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Counting days excluding holiday and weekends

There is a couple of messages regarding this but I have found the easiest might be this code by creating a calendar table and number 1-7 the days. But I also included a number 8 for publich holiday. This code also counts if start date and end date is on the same date that it is 1 where a lot does not count it. The problem that I'm facing is in the or statement where it looks like you can only have two arguments where I need their either 1, 7 and 😎 as listed below

 

Counting =
CALCULATE (
COUNTROWS ( 'Calendar' ),
FILTER (
'Calendar',
AND (
'Calendar'[Date] >= 'Leave'[Leave Start Date],
'Calendar'[Date] <= Leave[Leave End Date]
)
),
OR ( 'Calendar'[DayNumber] = 1, 'Calendar'[DayNumber] = 7, 'Calendar'[DayNumber] = 8 )
1 ACCEPTED SOLUTION

Hi @Anonymous 

 

Try this then as a cal. column:

Counting =
CALCULATE (
    COUNTROWS ( 'Calendar' ),
    FILTER (
        ALL ( 'Calendar' ),
        'Calendar'[Date] >= 'Leave'[Leave Start Date]
            && 'Calendar'[Date] <='Leave'[Leave End Date]
            && 'Calendar'[DayNumber] IN { 2, 3, 4, 5, 6 }
    )
)

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

As a calculated colomn

NoLeave StartLeave End
10023/03/202123/03/2021
20025/03/202130/03/2021
10026/03/202128/03/2021
3001/04/20213/04/2021
30010/04/202111/04/2021

Hi @Anonymous 

 

Try this then as a cal. column:

Counting =
CALCULATE (
    COUNTROWS ( 'Calendar' ),
    FILTER (
        ALL ( 'Calendar' ),
        'Calendar'[Date] >= 'Leave'[Leave Start Date]
            && 'Calendar'[Date] <='Leave'[Leave End Date]
            && 'Calendar'[DayNumber] IN { 2, 3, 4, 5, 6 }
    )
)

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

Anonymous
Not applicable

Thanks for the quick response. I tried it but it just returns blanks although should be days to count

@Anonymous 

 

Can you pleae share a sample of your tables in a text format?

 

Do want a measure? or calculated column?

 

Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

VahidDM
Super User
Super User

Hi @Anonymous 

 

Try this:

Counting =
CALCULATE (
    COUNTROWS ( 'Calendar' ),
    FILTER (
        ALL ( 'Calendar' ),
        'Calendar'[Date] >= MAX ( 'Leave'[Leave Start Date] )
            && 'Calendar'[Date] <= MAX ( 'Leave'[Leave End Date] )
            && 'Calendar'[DayNumber] IN { 2, 3, 4, 5, 6 }
    )
)

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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