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

DATEDIFF without weekend is giving wrong outputs

I have created a table which contains two dates, I just want to calculate the difference between them. Please see the file:

https://drive.google.com/file/d/17bisKyaR0DaM9A6wPrnyMwvi5StFPbMq/view?usp=sharing

 

I don't understand why the measure 'time in transit' is shorter than the measure 'Time in transit (without weekend).

 

I created a seperate table with all the days as of 2022-01-01.

 

 

 

1 ACCEPTED SOLUTION

@Spartanos 
If you want to omit one day from the date, is from the manifest or delivery date? What if you have the same date for both?  However, I change the two formauls as follows, please check

Time in Transit = 
IF(
    [Manifest Date] < [Date Delivered],
    DATEDIFF(
        [Manifest Date],[Date Delivered],DAY
    ) 
)
Time in Transit (Without weekend) = 
IF(
    [Manifest Date] < [Date Delivered],
    COUNTROWS(
        FILTER(
            CALENDAR( [Manifest Date] + 1,  [Date Delivered] ),
            WEEKDAY([Date],2) < 6
        )
    )

)



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

3 REPLIES 3
Spartanos
Helper II
Helper II

Hi, this works, thanks. But I want to adjust it a little bit. If the manifest date is for instance 23/02/2022 and Date delivered is 24/02/2022, I want that time in transit  is just one day,  for both measures.  So I have to do for both measures -1 day?

@Spartanos 
If you want to omit one day from the date, is from the manifest or delivery date? What if you have the same date for both?  However, I change the two formauls as follows, please check

Time in Transit = 
IF(
    [Manifest Date] < [Date Delivered],
    DATEDIFF(
        [Manifest Date],[Date Delivered],DAY
    ) 
)
Time in Transit (Without weekend) = 
IF(
    [Manifest Date] < [Date Delivered],
    COUNTROWS(
        FILTER(
            CALENDAR( [Manifest Date] + 1,  [Date Delivered] ),
            WEEKDAY([Date],2) < 6
        )
    )

)



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Fowmy
Super User
Super User

@Spartanos 
I modifed the formula in both the columns, please check and let me know:

 

Time in Transit = 
IF(
    [Manifest Date] <= [Date Delivered],
    DATEDIFF(
        [Manifest Date],[Date Delivered],DAY
    ) + 1
)

 

 

 

Time in Transit (Without weekend) = 
IF(
    [Manifest Date] <= [Date Delivered],
    COUNTROWS(
        FILTER(
            CALENDAR( [Manifest Date] , [Date Delivered] ),
            WEEKDAY([Date],2) < 6
        )
    )
)

 


File is attached below

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

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.