Forum Discussion
rnehrboss
4 years agoHelper II
Creating a last maximum? calculation
I'd like to create a measure that looks through last records finds the local max (100 in this example) and then uses the time and battery level from that record, along with the most recent local min ...
ryan_mayu
4 years agoSuper User
maybe you can try this
Measure =
VAR _localmax=max('Table'[Battery])
VAR _MAX=MAX('Table'[created Time])
VAR _last=maxx(FILTER('Table','Table'[created Time]=_MAX),'Table'[Battery])
VAR _lastmaxtime=maxx(FILTER('Table','Table'[Battery]=_localmax),'Table'[created Time])
VAR _m=DATEDIFF(_lastmaxtime,_MAX,MINUTE)
VAR _hour=roundup((_m/60),0)
VAR _min=mod(_m,60)
return (_localmax-_last)&"% used in "& _hour &" Hours and "&_min&" Minutes"
pls see the attachment below
rnehrboss
4 years agoHelper II
Thanks Ryan, Great solution and will kind of work if the battery is always charged to 100%. If the last charge was unnplugged at 90% (which would be the local max), I think the _lastmaxtime var will go all the way back to the last 100%.