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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
zaidmasad
Helper III
Helper III

Calculating transit time excluding situational dates and holidays for origin and destination

Capture.JPG

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @zaidmasad,

 

You can take a look a below formula which used to get transmit date range(except the situational dates)

 

Calculated column: get date range except specify date and normal holiday(saturday and sunday)

Detail = 
var calendarTable= CALENDAR([Start Date],[End Date])
var exceptDate=CALCULATETABLE(VALUES(Sheet3[situation Date]),FILTER(ALL(Sheet3),[Entity]=EARLIER(Sheet2[Origin Entity])||[Entity]=EARLIER(Sheet2[Destination Entity])))
var filtered=ADDCOLUMNS(EXCEPT(calendarTable,exceptDate),"Day Of Week",WEEKDAY([Date],1))
return
CONCATENATEX(FILTER(filtered,[Day Of Week]<>1&&[Day Of Week]<>7),[Date],",")

Count =
var calendarTable= CALENDAR([Start Date],[End Date])
var exceptDate=CALCULATETABLE(VALUES(Sheet3[situation Date]),FILTER(ALL(Sheet3),[Entity]=EARLIER(Sheet2[Origin Entity])||[Entity]=EARLIER(Sheet2[Destination Entity])))
var filtered=ADDCOLUMNS(EXCEPT(calendarTable,exceptDate),"Day Of Week",WEEKDAY([Date],1))
return
COUNTROWS(FILTER(filtered,[Day Of Week]<>1&&[Day Of Week]<>7))

4.PNG

 

 

>>Also some of the countries have weekend as Saturday and Sunday, the other have weekends as Friday and Saturday.

You need to create a table to store these specific day of week, then excluded from current date range.

 

Regards,

Xiaoxin Sheng

View solution in original post

8 REPLIES 8
zaidmasad
Helper III
Helper III

@Anonymous I can share with you the file but I dont know how actually.

Anonymous
Not applicable

HI @zaidmasad,

 

You can use below formula to calculate the transit time except the holiday.

Count = COUNTROWS(FILTER(ADDCOLUMNS(CALENDAR([Start Date],[End Date]),"Day Of Week",WEEKDAY([Date],1)),[Day Of Week]<>1&&[Day Of Week]<>7)) 

1.PNG

 

 

In addition, I'm not so sure how to use the situational date table, can you share some detail information?

 

Regards,

Xianxin Sheng

@Anonymous Also some of the countries have weekend as Saturday and Sunday, the other have weekends as Friday and Saturday. Can this be included in the calculation? Thank you very much for your help

Anonymous
Not applicable

Hi @zaidmasad,

 

You can take a look a below formula which used to get transmit date range(except the situational dates)

 

Calculated column: get date range except specify date and normal holiday(saturday and sunday)

Detail = 
var calendarTable= CALENDAR([Start Date],[End Date])
var exceptDate=CALCULATETABLE(VALUES(Sheet3[situation Date]),FILTER(ALL(Sheet3),[Entity]=EARLIER(Sheet2[Origin Entity])||[Entity]=EARLIER(Sheet2[Destination Entity])))
var filtered=ADDCOLUMNS(EXCEPT(calendarTable,exceptDate),"Day Of Week",WEEKDAY([Date],1))
return
CONCATENATEX(FILTER(filtered,[Day Of Week]<>1&&[Day Of Week]<>7),[Date],",")

Count =
var calendarTable= CALENDAR([Start Date],[End Date])
var exceptDate=CALCULATETABLE(VALUES(Sheet3[situation Date]),FILTER(ALL(Sheet3),[Entity]=EARLIER(Sheet2[Origin Entity])||[Entity]=EARLIER(Sheet2[Destination Entity])))
var filtered=ADDCOLUMNS(EXCEPT(calendarTable,exceptDate),"Day Of Week",WEEKDAY([Date],1))
return
COUNTROWS(FILTER(filtered,[Day Of Week]<>1&&[Day Of Week]<>7))

4.PNG

 

 

>>Also some of the countries have weekend as Saturday and Sunday, the other have weekends as Friday and Saturday.

You need to create a table to store these specific day of week, then excluded from current date range.

 

Regards,

Xiaoxin Sheng

@Anonymous Hello again,

 

I still have a problem with calculating the transit time, now the formula to exclude situational dates is working well. but I need a formula to exclude holidays based on the country.

 

I have a table for holildays that looks as below for the entities regardless if it is a destination or origin:

 

Capture.JPG

 

What should the new formula for calculating the tranist time be?

 

Thank you very much for your help.

Hi @Anonymous,

 

Can you please explain me exactly how does this function work? I am new to these kind of function and powerBI.

 

Thank you very much

Anonymous
Not applicable

Hi @zaidmasad,

 

Some comment of the formula:

 

Detail = 
var calendarTable= CALENDAR([Start Date],[End Date]) //use "start date" and "end date" from current row content to create a calendar table.
var exceptDate=CALCULATETABLE(VALUES(Sheet3[situation Date]),FILTER(ALL(Sheet3),[Entity]=EARLIER(Sheet2[Origin Entity])||[Entity]=EARLIER(Sheet2[Destination Entity]))) //use current "origin entity" and "destination entity" to filter situation date from situation table.
var filtered=ADDCOLUMNS(EXCEPT(calendarTable,exceptDate),"Day Of Week",WEEKDAY([Date],1)) // add "day of week" column to calendar table(it used to filter normal holiday)
return
CONCATENATEX(FILTER(filtered,[Day Of Week]<>1&&[Day Of Week]<>7),[Date],",") // filter date and merge them to text
COUNTROWS(FILTER(filtered,[Day Of Week]<>1&&[Day Of Week]<>7)) //filter date and get count of days.

 

 

BTW, you can also refer to below link which about dax functions:

DAX Function Reference

 

Regards,

Xiaoxin Sheng 

@Anonymous 

 Capture1.JPG

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

May 2025 Monthly Update

Fabric Community Update - May 2025

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