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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Same day date difference resulting in negative value

Hello PBi Community   -   So I have the formula below which works great for calculating the number of weekdays between two dates.    I then use the result of this to tell me whether a shipment is on time, or late.    

 

One strange issue I have is that if the due date and the ship date fall on the exact same date, the result =  -1.      Ideally, it should just say 0.  

 

Any idea how to fix this?  

 

negative 1.png

 

Due vs Ship Weekday Count =
If( 'Flu Shipped'[Due Date] < 'Flu Shipped'[Date Shipped],
CALCULATE(
COUNTROWS( DateTable ),
DATESBETWEEN ( DateTable[Date],  'Flu Shipped'[Due Date], 'Flu Shipped'[Date Shipped]),DateTable[DateIsWorkingDay]= True,
    ALL ( 'Flu Shipped' )
),

CALCULATE(
COUNTROWS( DateTable ),
DATESBETWEEN ( DateTable[Date], 'Flu Shipped'[Date Shipped], 'Flu Shipped'[Due Date]), DateTable[DateIsWorkingDay]=True,
    ALL ( 'Flu Shipped' )
) * -1)
1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Hey @Anonymous ,

 

as both dates are equal, the FALSE branch will be evaluated, and this means that the 1 row will be multiplied with -1

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

3 REPLIES 3
TomMartens
Super User
Super User

Hey @Anonymous ,

 

as both dates are equal, the FALSE branch will be evaluated, and this means that the 1 row will be multiplied with -1

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
Anonymous
Not applicable

Thanks Tom....I realized I just needed to add an = sign to my first statement....then it made the days where the due date and ship date were the same to say  "1"   instead of  "-1".       Which technically is correct as the formula is counting the actual number of weekdays in the date range...which in those cases is "1"  (not Zero).      Thanks for pointing me in the right direction!

Anonymous
Not applicable

Thanks Tom. Is there an easy fix?

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.