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
BerlinAlexander
Helper II
Helper II

DAX: Count the number of weekdays (not weekends) TM

Hi,

 

I want to have something similar to "countifs" - I want to count the days in the current month which aren't Saturdays or Sundays.

 

I work with an online DB and can't create additional columns.

 

My column 'Date'[Date] lists all dates continously, day by day, including weekends.

 

I have this, which doesn't work:

 

JustWorkdaysThisMonth = CALCULATE(

    COUNTROWS(DATESMTD('Date'[Date])),

    FILTER('Date', WEEKDAY('Date'[Date]="Saturday") || WEEKDAY('Date'[Date]="Sunday"))

)

 

Do you have any advice?

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@BerlinAlexander , Try like

 


JustWorkdaysThisMonth = CALCULATE(
COUNTROWS(FILTER('Date', WEEKDAY('Date'[Date],2) <6)),DATESMTD('Date'[Date])
)

 

or


JustWorkdaysThisMonth = CALCULATE(
COUNTROWS('Date'),DATESMTD('Date'[Date])
FILTER('Date', WEEKDAY('Date'[Date],2) <6)
)

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

4 REPLIES 4
AilleryO
Memorable Member
Memorable Member

Hi,

 

Could you try something like this :

IsWeekDay= SWITCH (MyCalendar[WeekDayName]; "sunday" ; 0; "saturday";0;1)

Then you can do a sum on this column IsWeekDay.

 

Hope this helps

amitchandak
Super User
Super User

@BerlinAlexander , Try like

 


JustWorkdaysThisMonth = CALCULATE(
COUNTROWS(FILTER('Date', WEEKDAY('Date'[Date],2) <6)),DATESMTD('Date'[Date])
)

 

or


JustWorkdaysThisMonth = CALCULATE(
COUNTROWS('Date'),DATESMTD('Date'[Date])
FILTER('Date', WEEKDAY('Date'[Date],2) <6)
)

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks a lot. I have one additional question.

 

It seems that this is considering the whole month.

 

If I wanted to have MTD instead (i.e. today is July 15th, so I would like to consider just the time since the month beginning till July 15th), how should I change the code?

Hi,

 

You have the STARTOFMONTH() function that should do the trick.

 

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.