I'm trying to do a formula field in a saved search...
# general
b
I'm trying to do a formula field in a saved search and keep running into invalid expression or possible divide by 0 error messages - so clearly my formula trial and error process isn't working. I have 2 formula columns (both summary type = sum) that I need to then find the % total of column 1 to column 2. Column 1's formula (numeric) is sum({field1}+{field2}+{field3}). Column 2's formula (also numeric) is nvl({debitamount},0) - NVL({creditamount},0). I'm trying to calculate the percentage by sum({field1}+{field2}+{field3})/sum(nvl({debitamount},0) - NVL({creditamount},0)) but it's clearly wrong. Any tips?
c
With your denominator you're going to want to do NULLIF({denominator},0) to avoid the divide by zero error. I have to do this with a lot of my formulas. Suiteanswers 17946 talks about this error.
✔️ 1
k
Chloe's response is the correct path forward
sum({field1}+{field2}+{field3})/nullif(sum(nvl({debitamount},0) - NVL({creditamount},0)),0)
Looks like there might be an extra parenthesis in that though.
b
Thank you both! I was trying to use NULLIF, but using it wrong. This got me what I needed. Thank you!!