cancel
Showing results for
Did you mean:
Highlighted
Helper II

## Calculate no. of working days that have passed in the year so far

Hi,

I have a calendar table where I'm using a calculated column to calculate the no. of working days in each month this year.

Based on this column and the current date, I want to calculate the no. of working days that have passed year to date. Please see screenshot below for no. of working days by month. Essentially, I want this formula to return 21 for January, 20 for Feb and 19 for March (since based on today's date we have 2 more working days left in March) and the total to be 60. I have tried a few different formulas but can't seem to get the desired result, mainly the total is almost always incorrect.

Thank you for any suggestions!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User IV

## Re: Calculate no. of working days that have passed in the year so far

YTD Sales = CALCULATE(SUM('Date'[Working Day]),DATESYTD(('Date'[Date]),"12/31"))

But for that, you need have a filter of the date on the page

or try like

YTD Sales = CALCULATE(SUM('Date'[Working Day]),DATESYTD(('Date'[Date]),"12/31"),'Date'[Date]<=today())

My Recent Blog -Week is not so Weak Connect on Linkedin

Proud to be a Super User!

4 REPLIES 4
Highlighted
Super User IV

## Re: Calculate no. of working days that have passed in the year so far

YTD Sales = CALCULATE(SUM('Date'[Working Day]),DATESYTD(('Date'[Date]),"12/31"))

But for that, you need have a filter of the date on the page

or try like

YTD Sales = CALCULATE(SUM('Date'[Working Day]),DATESYTD(('Date'[Date]),"12/31"),'Date'[Date]<=today())

My Recent Blog -Week is not so Weak Connect on Linkedin

Proud to be a Super User!

Highlighted
Super User IV

## Re: Calculate no. of working days that have passed in the year so far

If you have a Calendar, then you should be able to create a column like:

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

You should then just be able to SUM the Working Day column to get the number of working days and the totals should be correct.

If you are using some kind of measure, you may have a measure totals issue. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907

---------------------------------------

Putting square pegs in round holes since 1972.

##### I have a NEW book! DAX Cookbook from Packt
Over 120 DAX Recipes!

Proud to be a Super User!

Highlighted
Community Support

## Re: Calculate no. of working days that have passed in the year so far

Hi @kartiklal18

Take year 2020 for example：

1.Create a calendar table using below dax expression:

`` table = CALENDAR(DATE(2020,1,1),DATE(2020,12,31)) ``

2.Then create 3 calculated columns:

`` Month = FORMAT('table'[Date],"MMMM") ``

``weekday = WEEKDAY('table'[Date],2)``

``Working day = IF('table'[weekday]<>6&&'table'[weekday]<>7,1,0)``

3.Fianlly create a measure as below:

``Measure = IF(MONTH(MAX('table'[Date]))=MONTH(TODAY()),CALCULATE(SUM('table'[Working day]),'table'[Date]<=TODAY()),SUM('table'[Working day]))``

And you will see:

Best Regards,
Kelly

Highlighted
Helper II

## Re: Calculate no. of working days that have passed in the year so far

Hi all,

Thanks for all your suggestions. @amitchandak , your solution works and its what I needed.

Announcements

#### August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

#### Super Users of the Quarter - Q2 2020

Who are our Super User Superstars? Who made it to the top of the leaderboards? Get the answers!

#### Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

#### Community Summit Australia – Join Online!

Be a part of the leading Microsoft Business Applications digital event, curated for the APAC community.

Top Solution Authors
Top Kudoed Authors