How to calculate percentage when old value is ZERO

后端 未结 9 975
甜味超标
甜味超标 2021-01-31 16:20

I need the logic for the following situation. I am clueless in doing this.

Consider for January I have 10$ revenue and f

相关标签:
9条回答
  • 2021-01-31 17:02

    There are a couple of things to consider.

    If your growth is 0 for that month, it'd be 0 in change from 0. So it is meaningful in that sense. You could adjust by adding a small number, so it'd be change from 0.1 to 0.1. Then change and percentage change would be 0 and 0%.

    Then to think about case where you change from 0 to 20. Such practice would result in massive reporting issues. Depending on what small number you choose to add, eg if you use 0.1 or 0.001, your percentage change would be 100 fold difference. So there is a problem with such practice.

    It is possible however if you have a change from 1 to 20, then the %change would be 19/1=1900%. Here the % change doesn't make too much sense when you start off so low, it becomes very sensitive to any change and may skew your results if other data points are on different scale.

    So it is important to understand your data, and in this case, how frequent you encounter 0s and extreme numbers in your data.

    0 讨论(0)
  • 2021-01-31 17:07

    If you're required to show growth as a percentage it's customary to display [NaN] or something similar in these cases. A growth rate, on the other hand, would be reported in this case as $/month. So in your example for April the growth rate would be calculated as ((20-0)/1.

    In any event, determining the correct method for reporting this special case is a user decision. Is it covered in your user requirements?

    0 讨论(0)
  • 2021-01-31 17:08

    It should be (new minus old)/mod avg of old and new With a special case when both val are zeros

    0 讨论(0)
提交回复
热议问题