Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Helper III
Helper III

Convert DAX to M - calculate business days


I have a table with columns Sale_Date and Post_Date. I need to calculate the business days between Sale_Date and Post_Date.

I have a caculated column to calculate the business days, but I need to convert it to M so that I can create a column inPower Query.


CountofBusinessdays = COUNTX ( Calendar, Calendar[Date] > 'Table'[Sale_Date]

                                                &&  Calendar, Calendar[Date] <= 'Table'[Post_Date]

                                                && Calendar[IsBusinessday] = 1 ) , 

                                      Calendar[Date] )


How to convert the abow DAX to M?


Thank you so much!

Community Support
Community Support

Hi , @Harry_Tran 

According to your description, you wan to convert the dax to M code.

This is my test data:



We can click "Custom Column" in the 'Table' and enter this:


Table.RowCount(Table.SelectRows(Calendar,(x)=>x[Date]>=[Sale_Date] and x[Date]<=[Post_Date] and x[IsBusinessday]=1))

Then we can get the result:




If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem. (You can also upload you sample .pbix [without sensitive data] to the OneDrive and share with the OneDrive link to me ! )

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 


Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly


Helpful resources

PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

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

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors