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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
GarlonYau
Helper I
Helper I

Calculating the net working days using M

Hi Everyone,

 

I see a lot of posts on here about how to calculate the net working days using DAX. However I don't see anyone showing the same solution using M. Reason I want to add this as a column in PowerQuery is so that I can group the results. That's why I need to have a column that I can apply conditional logic to.

 

Scenario:

I have a date dimension table called "Date" with a column called "Working Days excl. Holidays" that returns a true or false value on whether it is a working day or not. TRUE = Working Day, FALSE = Not a working day.

 

I have another table, called "NCReport" that contains the column "NCR_Date" and "Today's Date". Essentially, what I want to do is to add a new column in this table that will calculate the number of working days between "NCR_Date" and "Today's Date", using "Working Days excl. Holidays" = TRUE.

 

Thanks in advance for your help!

2 REPLIES 2
sturlaws
Resident Rockstar
Resident Rockstar

Hi,

 

this could probably be solved in much more elegant way, but this is one way of getting the number of workdays

In the NCReport table, add a custom column with this code

=List.Numbers([NCR_date],[Today]-[NCR]+1)

and expand this to new rows. This will give you one row for each day between NCR_date and today. From the Home tab, use Merge queries, and merge NCReport with your dimDate on the column you just created. Expand the resulting column, and choose only your WorkingDay column. Then on the transform tab, use Group By, and group NCReport by NCR_date and Today, and for the new column do a sum over the WorkingDay column from the merge. If working day is true/false, you might have to convert it to 1/0 to get the sum to work

Hey Sturlaws, thanks for the suggestion. I see where you're going with this, but I don't think that's going to work as I have tens of thousands of rows already in my NCReport table, in addition, if I'm expanding each row by the number of days between NCR_Date to Today's date. it's going to get to an unmanageable size...

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! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.