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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
goodhvnting
Frequent Visitor

Calculate number of weekends (Fridays and Saturdays) between two dates

Hello!

 

I've been searching this community for a solution but I don't believe this has been answered in my specific scenario. Hoping someone can help me with the following problem:

 

I want to calculate the number of weekend nights (Friday and Saturdays) between two dates. I have the following columns:

 

PERMIT_START_DT
PERMIT_END_DT

 

I'd like to create a new column (not measure) that tells me how many weekend nights are between those two date columns. 

 

Much appreciated! 

1 ACCEPTED SOLUTION

Somehow I was able to solve my own question! Thank you to davehus for trying to help me. 

 

This is the formula I used to get the answer to my question: 

 

Weekend_Nights = COUNTROWS(FILTER(CALENDAR(RAP_Permits_to_Postal_Code[PERMIT_START_DT],RAP_Permits_to_Postal_Code[PERMIT_END_DT]), WEEKDAY([Date]) in {6,7} ))

View solution in original post

8 REPLIES 8
davehus
Memorable Member
Memorable Member

Hi @goodhvnting ,

 

Are you happy for the column to only update on refresh as this will be the case with a calculated column?

 

 

Yes, that works for me. Thank you! 

This is with DAX. You can do it with powerquery either. Swap Date() for your Permit_start

 

IsWeekend = IF(AND(OR(WEEKDAY('Date Table'[DateKey])=7,WEEKDAY('Date Table'[DateKey])=1),AND('Date Table'[DateKey]>date(2021,01,01),'Date Table'[DateKey]<DATE(2021,01,31))),1,0)
 
Did I help you today? Please accept my solution and hit the Kudos button.
 

Thanks for the response. 

Finding this solution a little confusing... can you confirm that the DAX formula is used in the "New Column" function? 

Where would the PERMIT_START_DT and PERMIT_END_DT columns be used? These columns are in a sepearate table not in a "Date Table".

 

Appreciate your time. 

Hi @goodhvnting , Yes it is. So the calculation is checking if the weekday is a Friday OR Saturday and the dates are between the start AND end date.  I've modified and test with a separate table and it works.

IsWeekend =
IF (
    AND (
        OR (
            WEEKDAY ( 'Date Table'[DateKey] ) = 6,
            WEEKDAY ( 'Date Table'[DateKey] ) = 7// Is it Friday or Saturday
        ),
        AND (
            'Date Table'[DateKey] > MAX ( Parameter[PERMIT_START_DT] ),
            'Date Table'[DateKey] < MAX ( Parameter[PERMIT_END_DT] )
        )
    ),
    1,
    0
)

 

davehus_0-1662495722590.png

 

Thanks again for your response. 

Apologies, my question may not have been very clear. 


I am trying to count the number of Fridays and Saturdays that occur between two dates. Not if it is a Friday or Saturday. 

Example:  

PERMIT_START_DTPERMIT_END_DT
Friday, August 23, 2019Sunday, August 25, 2019
Thursday, August 01, 2018Friday, August 03 2018
Friday, August 22, 2014Sunday, August 24, 2014

 

I want to create a new column using a DAX formula that will count the total number of Fridays AND saturdays between those 2 dates. It should look something like this: 

 

Weekend_Nights
2
1
2

 

Thanks again for your time and consideration. Truly appreciate it. 

Somehow I was able to solve my own question! Thank you to davehus for trying to help me. 

 

This is the formula I used to get the answer to my question: 

 

Weekend_Nights = COUNTROWS(FILTER(CALENDAR(RAP_Permits_to_Postal_Code[PERMIT_START_DT],RAP_Permits_to_Postal_Code[PERMIT_END_DT]), WEEKDAY([Date]) in {6,7} ))

Hi @goodhvnting , 

You would have got the same result once the columnn was dragged into the canvas. See below.

 

davehus_0-1662499172683.png

 

Glad you got sorted.

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.