March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
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, would look like this -
START | END | COMPLETE |
14-NOV-2019 19:00 | 15-NOV-2019 07:00 | 100% |
15-NOV-2019 07:00 | 15-NOV-2019 19:00 | 50% |
15-NOV-2019 19:00 | 16-NOV-2019 07:00 | 0% |
Basically, i need to show 100% for completed shifts, 0% for future shifts, and a % value of how far through the current shift we are...
In Excel i use this, which works great -
=IF(END<NOW(),1,IF(START>NOW(),0,1-((END-NOW())/(END-START))))
Any help would be appreciated!
M
Solved! Go to Solution.
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)
@MickBrowning please try this and check if it is working as expected.
Measure =
VAR _start = MAX(Test[START])
VAR _end = MAX(Test[END])
VAR _now = NOW()
VAR diff1 = DATEDIFF(_now,_end,HOUR)
VAR diff2 = DATEDIFF(_start,_end,HOUR)
RETURN IF(diff1>0,DIVIDE((diff2-diff1),diff2,0),1)
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)
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
21 | |
14 | |
11 | |
8 | |
5 |
User | Count |
---|---|
26 | |
21 | |
20 | |
14 | |
10 |