Hi @gcusello , Apologies, in an attempt to anonymize my search earlier I have made some errors, which have made it seem confusing, so this is the corrected code with other variable so that maybe it would be easier to understand my dilemma. | mstats span=1m earliest(monitor) AS first latest(monitor) AS last max(monitor) AS max WHERE index=organizationmetric AND internal_name="SR01"
| autoregress last AS lastlast
| eval diff = if(first = lastlast, 0,if(first-lastlast<0,0,first-lastlast))
| eval divmaxlast = round(max-last,0)
| eval meter = round(if(max=last,last-first,if(last<max,if(divmaxlast<2,last-first,max-first+last),max-first+last))) + diff
| eval date=strftime(_time,"%Y-%m-%V")
| timechart span=1w sum(meter) AS output the other metric names are "SR02" "SR03" "SR04" Thanks and sorry again for the confusion
... View more