Calculated column value with IF statements

I created a calculated column named"total value". And I have some other columns named "Value1", "Value2", "Value3". And I created another Choice condition column named"Type".

I want to archive that if "Type" equals "Sum.", "Total value" returns `SUM("Value1", "Value2",Value3")`.

If "Type" equals "Avg.", "Total value" returns `AVERAGE("Value1","Value2","Value3")`.

So I add following forum for "Total value"

``````=IF(OR([Type]="Sum.",[Type]="Avg."),"SUM([Value1],[Value2],[Value3])","AVERAGE([Value1],[Value2],[Value3])")
``````

But it failed, it's just display the forum what I define above.

Who can help me to check this? And how to archive my target with other ideas?

I would remove the OR statement in your formula and have a nested IF instead.

I'm not sure how you created a Type column, when I try that it tells me Type is a reserved word, so for my test I used a field called CalcType.

Here is the formula that works for me. (I'm assuming each of the value fields are numeric, and also the result of the calculated field is numeric)

``````=IF([CalcType]="Sum.",SUM([Value1],[Value2],[Value3]),
IF([CalcType]="Avg.",AVERAGE([Value1],[Value2],[Value3]),
0))
``````

Try:

``````=IF([Type]="Sum.",SUM([Value1],[Value2],[Value3]),AVERAGE([Value1],[Value2],[Value3]))
``````