I’m trying to make a formula work and it keeps giving me an error.
What I’m trying to achieve is to make the formula output a “0” when the column {aantal} is empty/null and when the column is not empty perform a calculation.
The formula is as follows:
IF({Aantal}=“0”, “”,
IF({Volt} = “230”,
({Vermogen per aansluiting} * {Aantal}) / {PF}, IF({Volt} = “400”,
({Vermogen per aansluiting} * {Aantal}) / (sqrt(3) * {PF})
)))
As you can see the formula works when there’s data in the given columns, but when I want the KVA column to be 0, it gives me an error.
Thanks for any help in advance!
GCavin
(Gilles Cavin - Reinventing Formulas in monday.com)
2
Hi Joey,
The problem is with {PF}: you can’t divide by {PF} when {PF}=0. I know you believe that you took care of this by having the IF({Aantal}=0 condition but this is not the case. If you want to understand why, look at this article: A Simple Way to Handle Empty Columns and Avoid Errors in your Formulas | mdBoosters Blog (the explanation is in the paragraph titled “Eager vs Lazy Approach in IF Statements”).
It is not always easy to find a workaround, but in this case, it is relatively simple: replace {pf} by IF({pf}>0,{pf},1).
{pf}>0 will handle {pf}=0 or {pf} is empty.