function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AiyazAiyaz 

Variance formula (a - b) / b

Was wondering if anyone has created a formula field to calculate variance?
 
Currently I created three fields:
 
Current Sales year to Date
Lasts year's Sales year to date
 
Variance
 
 
Lets say this years sales was $5000, and last years was 0 dollars, how would you account for this in the formula field since you cannot use 0 in the denominator?
 
Any help would be great.
Thanks in Advance
 
 
1800-5000/1800
 
%Budget Variance% = (Actual – Budget) / Budget
JakesterJakester
3 ideas, in order of personal preference:

  1. Add an If() clause at the beginning - if it's going to have a 0 in denominator, return 0 and stop calculating
  2. Similar to #1, but instead, put a .01 in the denominator - this will return an absurdly high percentage, but some people prefer that to seeing a 0
  3. Make the formula field a text type of fomula, and then return an "N/A" or such if there's a 0 in the denominator. There are many drawbacks to working with it as text, but there is the advantage of being able to show an N/A
4th idea that occurred to me while writing, that I think I like the best. Do #1, then create a second formula field (this one is text, the first is a number) that looks at the results of #1 and returns "N/A" if there would a 0 in denom, but otherwise returns the result from #1. This way you can still work with the value as a number by referencing the first formula.
AiyazAiyaz

Jakester,

 

I actually got it running yesterday using your Idea#1, where I just returned a "0" value if denominator's variable equalled 0.  I was thinking of using the N/A, however when using the IF statement, if your dealing with Currency or Number, you have to return a currency or number it seems.

 

Thanks for the ideas!