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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Calculate dynamically No. of business days passed in a month.

Hi,

I have a table which already have Date and Revenue but I would like to create a column No. of working days passed (Column c) and then divide Column B by Column C to get Column D. But i am not able to find  away to dynamically calculate no. of business days passed. This is excluding weekends and holidays(4 JULY).Capture_3.PNG

1 ACCEPTED SOLUTION
v-xicai
Community Support
Community Support

Hi @Anonymous ,

 

You can create calendar table first, assuming you have created the Holiday table via Enter Data, then create relationships among the calendar table , Data table and Holiday table on date field, keep Cross filter direction as Both.

 

Table: DateDim = CALENDAR(MIN(Data[DATE]),MAX(Data[DATE]))

 

Secondly, create column and measure in Data table like DAX below.

 

Column: 

IsWorkDay = IF (WEEKDAY(MAX(DateDim[Date]),2)<=5 && COUNTX(RELATEDTABLE(Holiday),1)<1,1,0)



Measure: 

No. of working days passed = IF(MAX(Data[IsWorkDay])<>0,CALCULATE(COUNTX(FILTER(ALLSELECTED(Data),Data[IsWorkDay]<>0),Data[IsWorkDay]),FILTER(ALLSELECTED(Data),Data[OrderDate]<=MAX(Data[OrderDate]))),BLANK())

 

Best Regards,

Amy

 

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

 

View solution in original post

1 REPLY 1
v-xicai
Community Support
Community Support

Hi @Anonymous ,

 

You can create calendar table first, assuming you have created the Holiday table via Enter Data, then create relationships among the calendar table , Data table and Holiday table on date field, keep Cross filter direction as Both.

 

Table: DateDim = CALENDAR(MIN(Data[DATE]),MAX(Data[DATE]))

 

Secondly, create column and measure in Data table like DAX below.

 

Column: 

IsWorkDay = IF (WEEKDAY(MAX(DateDim[Date]),2)<=5 && COUNTX(RELATEDTABLE(Holiday),1)<1,1,0)



Measure: 

No. of working days passed = IF(MAX(Data[IsWorkDay])<>0,CALCULATE(COUNTX(FILTER(ALLSELECTED(Data),Data[IsWorkDay]<>0),Data[IsWorkDay]),FILTER(ALLSELECTED(Data),Data[OrderDate]<=MAX(Data[OrderDate]))),BLANK())

 

Best Regards,

Amy

 

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

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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