Forum Discussion
Jolyon
9 years agoHelper III
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...
- 9 years ago
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.
Eric_Zhang
9 years agoMicrosoft Employee
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.
Jolyon
9 years agoHelper III
thank you all kindly!!
I calculated the Time between = ROUND((24, * (Table1[Closed Date]-Table1[Open Date]));1)
and then used SWITCH loop.
But your solution is of course more exquisite;)