YoY Calculate error

OT already in calculation, OT=sum({otunits})/sum({onunits}+{latunits})

this year data i use: ifelse(dateDiff({latest_datetime},now(),“YYYY”)=0, OT,0)
last year data i use: ifelse(dateDiff({latest_datetime},now(),“YYYY”)=1, OT,0)

it showed error with “mismatched aggregation. custom aggregations can’t contain both aggregate"sum” and non -aggregated fields “sum{“otunits”}”,in any combination.

what can i do for this, any suggestion?

Hi,

Can you try as below,

this year data i use: ifelse(dateDiff({latest_datetime},now(),“YYYY”)=0, OT,MAX(0) )

Thanks

1 Like

try MAX(0), but still showed the same error as above

Try putting the logic in your OT calcualtion and just return that.

OT_This_Year=sum(ifelse(dateDiff({latest_datetime},now(),“YYYY”)=0,{otunits},0)/sum({onunits}+{latunits})

thanks so much for your comment!! gave me an idea to fix it.

Successfully calculated as below.
OT_This_Year=sum(ifelse(dateDiff({latest_datetime},now(),“YYYY”)=0,{otunits},0))/sum(ifelse(dateDiff({latest_datetime},now(),“YYYY”)=0,{onunits}+{latunits}),0))