3 Replies Latest reply on Mar 29, 2018 12:55 PM by Jim Dehner

# Zero in the denominator

Hi,

So I need to know how to make a conditional statement or anything that will get me an outcome of .1 when I have a zero in the denominator of my calculated field.

This is so that I can have 100% as the outcome of this eventuality. I'm comparing actuals to plan for reference. when the plan is zero the actuals are 100 percent over the plan.

Thank you,

Kelly

• ###### 1. Re: Zero in the denominator

IF SUM(PLAN) = 0 then 1

else

SUM(ACTUAL)/SUM(PLAN)
END

Something like that.

• ###### 2. Re: Zero in the denominator

Yeah I forgot the else portion of that thank you

• ###### 3. Re: Zero in the denominator

Hi Kelly

Tableau will return a Null if it tries to divide by zero - so ifnull(attr(calculation),1)  will return a 1 but when you bring it to the viz tableau will aggregate it so you will need to take a Max(), Min() or Avg()

Jim

If this posts assists in resolving the question, please mark it helpful or as the 'correct answer' if it resolves the question. This will help other users find the same answer/resolution.  Thank you.