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
Surendra_thota
Helper II
Helper II

Is workingday column calculation in date dimension with Holidays range

i have implemented isworking day column with the refrence of one datecolumn in a  holidays refernece

 

IsWorkingDay = IF (NOT(DateTime[Day of Week]= "Saturday" || (DateTime[Day of Week]= "Sunday")) && COUNTX(RELATEDTABLE(Holidays),Date)<1,1,0)

 

Now the  Holidays refrence table splited  into holidaystartdate and HolidayEnddate.

 

How to handle this

1 ACCEPTED SOLUTION
v-sihou-msft
Employee
Employee

@Surendra_thota

 

Based on your description, now you have a holiday reference table which specifies a data range for each holiday. You want to add a isworkingday column in your date diemnsion table. Right?

 

I assume your Holiday table like below, and you build the relationship between two tables already:

 

45.PNG

 

46.PNG

 

You can apply the condition to check number of records in Holiday table where the current date is within the date range. Please create a calculated column below;

 

isworkingday = IF(WEEKDAY('Table'[Date],2)=6 || WEEKDAY('Table'[Date],2)=7 || 
	CALCULATE(COUNTROWS(Holiday),FILTER(Holiday,Holiday[start date]<='Table'[Date] && Holiday[end date]>='Table'[Date]))>0
	,0,1 )

123.PNG

 

 

234.PNG

 

Regards,

View solution in original post

4 REPLIES 4
v-sihou-msft
Employee
Employee

@Surendra_thota

 

Based on your description, now you have a holiday reference table which specifies a data range for each holiday. You want to add a isworkingday column in your date diemnsion table. Right?

 

I assume your Holiday table like below, and you build the relationship between two tables already:

 

45.PNG

 

46.PNG

 

You can apply the condition to check number of records in Holiday table where the current date is within the date range. Please create a calculated column below;

 

isworkingday = IF(WEEKDAY('Table'[Date],2)=6 || WEEKDAY('Table'[Date],2)=7 || 
	CALCULATE(COUNTROWS(Holiday),FILTER(Holiday,Holiday[start date]<='Table'[Date] && Holiday[end date]>='Table'[Date]))>0
	,0,1 )

123.PNG

 

 

234.PNG

 

Regards,

@v-sihou-msft

 

Thank you very much for the solution , we have used the same DAX  what you have mentioned in our trails , but the dotted relationship between date and endate is not created , so we are able get for date related to startdate ,  we dont aware that we can give relation twice  between the same tables.

Thanks for  this .

I'm using this syntax to calculate working days.   How do I handle null values when either the beginning or ending date is missing.

 

Production TAT =
SUMX (
    FILTER (
        'Calendar',
        'Calendar'[Date] >= MIN ( 'Order'[date_ProductionScheduled] )
            && 'Calendar'[Date] <= MAX ( 'Order'[date_ProductionDone] )
    ),
    'Calendar'[IsWorkingDay]
)

BhaveshPatel
Community Champion
Community Champion

You should check this community thread:

http://community.powerbi.com/t5/Desktop/Holiday-Calculation-From-Start-and-End-Date-to-quot-Aggregat...

 

Got some intersting stuff that can lead you to the final results.

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to give Kudos.

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.