Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
MickBrowning
New Member

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, would look like this -

 

STARTENDCOMPLETE
14-NOV-2019 19:0015-NOV-2019 07:00100%
15-NOV-2019 07:0015-NOV-2019 19:0050%
15-NOV-2019 19:0016-NOV-2019 07:000%

 

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

1 ACCEPTED 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)

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

@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)

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.