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

View all the Fabric Data Days sessions on demand. View schedule

Reply
carlosagarcia
Helper I
Helper I

Count working days for a month to get an average

Hello Everyone.

 

My intent is to calculate the number of working days for each month and display the number for the current month to get an average, For Example.

I created a report that tracks the number of lines processed, I would like to automatically devide the number of lines processed with the number of working days for the current month . I can do this manually  = Countoflines / 22 but I would have to change the number of working days each month. Will it be possible to have this automated so that when we switch to the next month it changes automatically?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @carlosagarcia,

Here is a calculated column expression that can be used to calculate the current month workdays(except weekend) based on date value, you can try it if helps:

CMonthWorkDay=
VAR currDate ='Date'[Date] 
RETURN
    COUNTROWS (
        FILTER (
            GENERATESERIES (
                DATE ( YEAR ( currDate ), MONTH ( currDate ), 1 ),
                DATE ( YEAR ( currDate ), MONTH ( currDate ) + 1, 1 ) - 1
            ),
            WEEKDAY ( [Date], 2 ) <= 5
        )
 )

Regards,

Xiaoxin Sheng

View solution in original post

11 REPLIES 11
Anonymous
Not applicable

Hi @carlosagarcia,

if you can please share some dummy data that keep the raw data structure and expected results. It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

Hello @Anonymous  What I want to do it is to count the working days for the current month.

For example  in this case July 2021 has 22 working days, I want to be able to see the working days displated on a card or a table so I can use it to get an average of lines processed.

 

This seems to be a good method but I am unable to recreate the MonthYear table.

 

carlosagarcia_0-1627563917467.png

 

 

https://stackoverflow.com/questions/59242331/calculate-number-of-working-days-based-on-a-month-and-year-column-dax

 

 

Anonymous
Not applicable

Hi @carlosagarcia,

Here is a calculated column expression that can be used to calculate the current month workdays(except weekend) based on date value, you can try it if helps:

CMonthWorkDay=
VAR currDate ='Date'[Date] 
RETURN
    COUNTROWS (
        FILTER (
            GENERATESERIES (
                DATE ( YEAR ( currDate ), MONTH ( currDate ), 1 ),
                DATE ( YEAR ( currDate ), MONTH ( currDate ) + 1, 1 ) - 1
            ),
            WEEKDAY ( [Date], 2 ) <= 5
        )
 )

Regards,

Xiaoxin Sheng

mahoneypat
Microsoft Employee
Microsoft Employee

Do you have a Date table with a column to indicate working days?  If so, you can use an expression like this

 

Count per WD =
VAR countoflines = [Your Count Measure]
VAR WD =
    CALCULATE ( COUNTROWS ( 'Date' ), 'Date'[IsWorkingDay] = "Y" )
RETURN
    DIVIDE ( countoflinesWD )

 

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


Hello Ma,

 

I do not have a date table, I treid different methods over the weekend with various posts and I could not find one that will give the total amount of days, it was always decending one by one.

 

This is as far as I got.

 

Date = CALENDAR (DATE(2021,1,1), DATE(2022,12,31))
 
WorkingDays =
VAR Year = YEAR( [Date] )
VAR Month = MONTH( [Date] )
VAR DatesInMonth = GENERATESERIES( [Date], DATE( Year, Month + 1, 1 ) - 1, 1 )
RETURN SUMX(
DatesInMonth,
IF( WEEKDAY( [Value] ) IN { 1, 7 }, 0, 1 )
)
 

 

@carlosagarcia 

WorkingDaysCurrentMonth = 
  VAR __Calendar = 
    ADDCOLUMNS(
      CALENDAR(DATE(2021,1,1),DATE(2021,12,31))
      "IsWorkDay", IF(WEEKDAY([Date],2),1,0)
    )
  VAR __Today = TODAY()
  VAR __Start = DATE(YEAR(__Today),MONTH(__Today),1)
  VAR __End = EOMONTH(__Today,0)
RETURN
  COUNTROWS(FILTER(__Calendar,[IsWorkDay]=1 && [Date] >=__Start && [Date]<=__End))


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hello @Greg_Deckler   Would you still be able to help me out?

@carlosagarcia Sorry, syntax error, should be:

"IsWorkDay", IF(WEEKDAY([Date],2)<6,1,0)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler  when you reffer to IsWorkDay what are you refering too?

The Dax query still does not recognize that name.  I really apreciate the help. 

 

carlosagarcia_0-1627394219310.png

 

 

 

Hello @Greg_Deckler , You lost me on the IsworkDay. I have attached a screen shot.

 

carlosagarcia_1-1627303268513.png

 

 

 

 

Greg_Deckler
Community Champion
Community Champion

@carlosagarcia So, generally, you can create a "IsWorkingDay" column in your calendar table using something like:

IsWorkingDay = IF(WEEKDAY([Date],2)<6,1,0)



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors