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
hmenco
Frequent Visitor

SHIPMENT LEADTIME EXCLUDING SUNDAYS AND HOLIDAYS

Hi!

 

I have been working on this equation for a while and it seems that I can't get the right answer CONSISTENTLY.

 

So I have here the Creation date (sales order placed) and Shipment end (sales order delivered). I have to get the difference between the two excluding the sundays and holidays.

On my calendar table, I have tagged 1 as working day, 0 for non-working (sundays and holidays)

image.png

 

 

 

 

 

 

 

I need to get the number of days between the Creation Date and Shipment End excluding the Sundays and Holidays.

I am using this DAX and it doesn't seem to work consistently.

 

Query1 = IF(ISBLANK(fcons[Shipment End]),BLANK(), CALCULATE(COUNTROWS('calendar'), DATESBETWEEN('calendar'[Date],fcons[Creation Date],fcons[Shipment End]-1), 'calendar'[IsNotSunday&NatHoliday]=1))
 

image.png

 

 

 

 

 

 

Hoping someone would help. Thanks!

 

2 ACCEPTED SOLUTIONS
PC2790
Community Champion
Community Champion

Hi @hmenco ,

 

Try to create a new DAX column with the following DAX code:

 

SubDtcrtnDtDiff =
VAR CalendarDays =
CALCULATE (
SUM ( 'calendar'[IsNotSunday&NatHoliday] ),
DATESBETWEEN (
'calendar'[Date],
'fcons'[Creation Date],
fcons[Shipment End] - 1
),
'calendar'[IsNotSunday&NatHoliday] = 1
)
VAR Net =
IF (
OR ( ISBLANK ( 'fcons'[Creation Date] ), ISBLANK ( fcons[Shipment End] ) ),
BLANK (),
IF (
DATEDIFF ( fcons[Shipment End], 'fcons'[Creation Date], DAY ) = 0,
0,
CalendarDays
)
)
RETURN
Net
 
Please mark this as a solution if it is exactly you were looking for.

View solution in original post

hmenco
Frequent Visitor

This worked as well, my DAX worked when I toggled it to Don't Summarize. Thanks!

hmenco_0-1610587057077.png

 

View solution in original post

2 REPLIES 2
hmenco
Frequent Visitor

This worked as well, my DAX worked when I toggled it to Don't Summarize. Thanks!

hmenco_0-1610587057077.png

 

PC2790
Community Champion
Community Champion

Hi @hmenco ,

 

Try to create a new DAX column with the following DAX code:

 

SubDtcrtnDtDiff =
VAR CalendarDays =
CALCULATE (
SUM ( 'calendar'[IsNotSunday&NatHoliday] ),
DATESBETWEEN (
'calendar'[Date],
'fcons'[Creation Date],
fcons[Shipment End] - 1
),
'calendar'[IsNotSunday&NatHoliday] = 1
)
VAR Net =
IF (
OR ( ISBLANK ( 'fcons'[Creation Date] ), ISBLANK ( fcons[Shipment End] ) ),
BLANK (),
IF (
DATEDIFF ( fcons[Shipment End], 'fcons'[Creation Date], DAY ) = 0,
0,
CalendarDays
)
)
RETURN
Net
 
Please mark this as a solution if it is exactly you were looking for.

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.

Top Solution Authors
Top Kudoed Authors