Calculated fields error

I have a few calculations am trying to compute but get syntax error

i tried this but keep on getting Error with the syntax
avgOver({Distance}, ifelse(

${Periodstarting} = 'Day’truncDate(‘DD’,{CREATE_DT}),

${Periodstarting} = 'Month’truncDate(‘MM’,{CREATE_DT}),

${Periodstarting} = 'Quarter’truncDate(‘Q’,{CREATE_DT}),


Also getting same error with this

ifelse(${Mileage_Unit} = ‘Mile’, sum({Distance })/(max({TOT_CHARGE_FAST})+max({TOT_CHARGE_SLOW}+max({TOT_CHARGE_RECUP}), sum({Distances })/1.60934/(max({TOT_CHARGE_FAST})+max({TOT_CHARGE_SLOW}+max({TOT_CHARGE_RECUP})))

hi @olusegun83,

I replied for the first inquiry in your another post. for the second inquiry, I think one of the parenthesis in the max({TOT_CHARGE_SLOW}) is missing. would you be able check?