Forum Discussion

Bcomm_student's avatar
Bcomm_student
Regular Visitor
5 months ago
Solved

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

  • 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

     

  • 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.

     

  • 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 ) )