Forum Discussion

gauravnarchal's avatar
gauravnarchal
Post Prodigy
5 years ago
Solved

Date Diff DAX

Hello   I need to create a calculation formula to get    If the days between the Ship date and the return date is between 0-2 days return “0-02 Days” If the days between the Ship date and the re...
  • mwegener's avatar
    5 years ago

    Hi gauravnarchal ,


    create a calculated column with this DAX formula.

    Diff =
    VAR diff =
        DATEDIFF ( 'Table'[Ship Date], 'Table'[Return Date], DAY )
    RETURN
        SWITCH (
            TRUE (),
            diff >= 0
                && diff <= 2, "0-02 Days",
            diff >= 3
                && diff <= 7, "03-07 Days",
            diff >= 8
                && diff <= 14, "08-14 Days",
            diff >= 15
                && diff <= 21, "15-21 Days",
            diff >= 22
                && diff <= 30, "22-30 Days",
            diff > 30, "above 31 Days",
            BLANK ()
        )