Forum Discussion

MickBrowning's avatar
MickBrowning
New Member
6 years ago
Solved

Percentage Of Time Period

Hello,   I am wondering how i could add a measure column to a table to show percentage complete of a time period.   So COMPLETE in the table below, if the current time was 15-NOV-2019 13:00, woul...
  • MickBrowning's avatar
    MickBrowning
    6 years ago

    Thanks Anonymous , a slight tweak and its working!

    The original returned a negative value for future dates, i need a zero.

    Measure = 
    VAR _start = MAX([START])
    VAR _end = MAX([END])
    VAR _now = NOW()
    VAR diff1 = DATEDIFF(_now,_end,HOUR)
    VAR diff2 = DATEDIFF(_start,_now, HOUR)
    VAR diff3 = DATEDIFF(_start,_end,HOUR)
    RETURN IF(diff1>0,IF(diff2>0,DIVIDE((diff3-diff1),diff3,0),0),1)