Ratio calculation
Posted: Wed Feb 15, 2012 9:34 am
Hi all,
Just a random question - most probably there will be no right or wrong answer
I am writing rules for ratios, like the following (margin calculation of turnover minus costs for example):
['MyRatio'] = ( ['A']-['B'] ) \ ['A'];
but my initial thought was to write it as:
['MyRatio'] = 1 - ['B'] \ ['A'];
Both terms are DB functions towards a cube with a great number of dimensions and detail. Form 2 will be shorter for notation.
I want to show 0 whenever A is 0, so the 2nd form will need an additional IF to test if A = 0 or not. Form 1 takes care of this as such.
What would you prefer if any? Just curious to see what you think of it.
Would there be a speed difference in the formulas as they are above, maybe because ['A'] is retrieved only once in formula 2? Or is it cached and the speed difference is minimal?
Have a great day,
Wim
Just a random question - most probably there will be no right or wrong answer

I am writing rules for ratios, like the following (margin calculation of turnover minus costs for example):
['MyRatio'] = ( ['A']-['B'] ) \ ['A'];
but my initial thought was to write it as:
['MyRatio'] = 1 - ['B'] \ ['A'];
Both terms are DB functions towards a cube with a great number of dimensions and detail. Form 2 will be shorter for notation.
I want to show 0 whenever A is 0, so the 2nd form will need an additional IF to test if A = 0 or not. Form 1 takes care of this as such.
What would you prefer if any? Just curious to see what you think of it.
Would there be a speed difference in the formulas as they are above, maybe because ['A'] is retrieved only once in formula 2? Or is it cached and the speed difference is minimal?
Have a great day,
Wim