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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Harry_Tran
Helper III
Helper III

Convert DAX to M - calculate business days

Hello,

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!

1 REPLY 1
v-yueyunzh-msft
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:

vyueyunzhmsft_0-1676426002283.png

vyueyunzhmsft_1-1676426009551.png

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

vyueyunzhmsft_2-1676426032888.png

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:

vyueyunzhmsft_3-1676426052068.png

 

 

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

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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