Forum Discussion
Need all my difference between dates to be positive
I'm doing a university assignment and part of the instructions is to show the time between an order and shipment date. Both dates came with hierarchies so I've made the column
Delivery days = Data[Order Date].[Day]-Data[Delivery Date].[Day]However, this caused many of my values to appear as negatives. I'm not entirely sure how I can make all of the positive unless there's a function specifically for dates. Thanks!
Use the full date columns and the DATEDIFF() function:
Delivery days = DATEDIFF ( Data[Order Date], Data[Delivery Date], DAY )If your assignment requires only positive values:
Delivery days = ABS( DATEDIFF ( Data[Order Date], Data[Delivery Date], DAY ) )
5 Replies
- Mauro89Super User
Hi Bcomm_student,
what you can try is to convert the data into integer and use the ABS() function to only get the absolut values.
If you only want positives meaning filtering the negatives out, make use of a filter set to values greater to zero.
Best regards!
PS: If you find this post helpful consider leaving kudos or mark it as solution
- ralf_antonResolver I
Hi,
der Deliveryday kann nur nach den Orderday liegen. Eine Lieferung kann niemals vor der Bestellung erfolgen.
Deshalb muss die Differenz aus dem größeren Datum (Deliveryday) minus dem kleineren Datum (Orderday) gebildet werden.
= Table.AddColumn(#"Geänderter Typ", "Different Days", each Number.From( [Delivery Date]-[Order Date]))Wenn Du ein negatives Ergebnis erhältst, dann ist da ein sicheres Indiz für Eingabefehler.
- cengizhanarslanSuper User
Use the full date columns and the DATEDIFF() function:
Delivery days = DATEDIFF ( Data[Order Date], Data[Delivery Date], DAY )If your assignment requires only positive values:
Delivery days = ABS( DATEDIFF ( Data[Order Date], Data[Delivery Date], DAY ) ) - v-saisrao-msftCommunity Support
Hi Bcomm_student,
Have you had a chance to review the solution we shared by Mauro89 ralf_anton cengizhanarslan ? If the issue persists, feel free to reply so we can help further.
Thank you.
- v-saisrao-msftCommunity Support
Hi Bcomm_student,
Checking in to see if your issue has been resolved. let us know if you still need any assistance.
Thank you.