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
atjt217
Helper III
Helper III

Calculate Number of Days for the Month excluding weekends

Hello, 

Would like to ask for some help please? I have 2 issues:

1) Is there a way to modify this formula to not count weekends?

CurrentDays_in_month = DATEDIFF(EOMONTH(NOW(),-1),(NOW()-1),day)
What this does is it counts the number of days for the current month except same day (10/1/2020-10/13/2020) 
 
2) Is there a formula that can count the number of days of the month without the weekends that will not be affected by a filter? The formula on my first question does not get affected by filters. Is there a way to modify it to fit to this? 
 
 

 

 
 
 
 
2 ACCEPTED SOLUTIONS
mahoneypat
Employee
Employee

Here is a measure expression that gives your desired result.

 

WD to Date This Month =
VAR __days =
    CALENDAR (
        EOMONTH (
            TODAY (),
            -1
        ) + 1,
        TODAY ()
    )
RETURN
    COUNTROWS (
        FILTER (
            __days,
            NOT (
                WEEKDAY ( [Date] )
                    IN {
                    1,
                    7
                }
            )
        )
    )

 

Regards,

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

Sure.  It is just a variation of the first one (just changed the 2nd term of the CALENDAR().

 

WD This Month =
VAR __days =
    CALENDAR (
        EOMONTH (
            TODAY (),
            -1
        ) + 1,
        EOMONTH (
            TODAY (),
            0
        )
    )
RETURN
    COUNTROWS (
        FILTER (
            __days,
            NOT (
                WEEKDAY ( [Date] )
                    IN {
                    1,
                    7
                }
            )
        )
    )

 

Regards,

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

5 REPLIES 5
atjt217
Helper III
Helper III

Actually I found the answer for number 2:

Count_Days_Month = DAY (
IF (
MONTH ( TODAY () ) = 12,
DATE ( YEAR ( TODAY () ) + 1, 1, 1 ),
DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ) + 1, 1 )
)
- 1
)
 
My only issue is how do i remove weekends on both of the calulations?

 

mahoneypat
Employee
Employee

Here is a measure expression that gives your desired result.

 

WD to Date This Month =
VAR __days =
    CALENDAR (
        EOMONTH (
            TODAY (),
            -1
        ) + 1,
        TODAY ()
    )
RETURN
    COUNTROWS (
        FILTER (
            __days,
            NOT (
                WEEKDAY ( [Date] )
                    IN {
                    1,
                    7
                }
            )
        )
    )

 

Regards,

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Its exactly what im looking for @mahoneypat.Thanks for helping me out with the first question! I hope you can also help me with the other one please? 

Sure.  It is just a variation of the first one (just changed the 2nd term of the CALENDAR().

 

WD This Month =
VAR __days =
    CALENDAR (
        EOMONTH (
            TODAY (),
            -1
        ) + 1,
        EOMONTH (
            TODAY (),
            0
        )
    )
RETURN
    COUNTROWS (
        FILTER (
            __days,
            NOT (
                WEEKDAY ( [Date] )
                    IN {
                    1,
                    7
                }
            )
        )
    )

 

Regards,

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Thank you so much! 😃 

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.