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
zaidmasad
Helper III
Helper III

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

Capture.JPG

1 ACCEPTED SOLUTION

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

8 REPLIES 8
zaidmasad
Helper III
Helper III

@v-shex-msft I can share with you the file but I dont know how actually.

v-shex-msft
Community Support
Community Support

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

@v-shex-msft 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

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

@v-shex-msft 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 @v-shex-msft,

 

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

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 

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help 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.