Forum Discussion

Jolyon's avatar
Jolyon
Helper III
9 years ago
Solved

Calculation with date/hours?

Hello dear community, I kindly ask for your help.   I have a table with different art of orders and their Open and Closed Date(in format dd: mm: yyyy hh:mm:ss). 1)Now I want to calculate th...
  • Eric_Zhang's avatar
    9 years ago

    Jolyon

     

    Please check a formula as below.

     

    Hours Between =
    VAR elapsedHours =
        DATEDIFF ( YourTable[Open Date], YourTable[Closed Date], HOUR )
    RETURN
        IF (
            ISBLANK ( YourTable[Closed Date] ),
            BLANK (),
            SWITCH (
                TRUE (),
                elapsedHours <= 12, "12",
                elapsedHours <= 24, "24",
                elapsedHours <= 36, "36",
                elapsedHours <= 48, "48",
                elapsedHours <= 72, "72",
                elapsedHours <= 240, "240",
                "Over 240"
            )
        )

     

     

    If it answers your question, please accept it as solution to close this thread. For any question, feel free to post.