旧值是零时如何计算百分比 [英] How to calculate percentage when old value is ZERO

查看:140
本文介绍了旧值是零时如何计算百分比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在以下情况下,我需要逻辑.我无能为力.

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

考虑一月,我有 10 $ 收入,二月,我有 20 $ 收入.

Consider for January I have 10$ revenue and for February I have 20$ revenue.

我的 增长 ((20-10)/10)*100% = 100%

如果我有 3月的收入为 0 $ .

然后我的 增长 ((0-10)/10)*100 % =-100 %.我应该称其为负百分比吗? (我知道它的放气)

Then my growth would be ((0-10)/10)*100 % =-100 %. Should I call this as negative percentage? (I know its deflation)

再走一步

如果现在我在 4月上有 20 $ 收入.

现在如何计算 增长 ?,请确保以下公式是错误的((20-0)/0)*100 %= ?????

我的基本问题是

  1. 除了上述方法以外,还有找到更好的增长率的解决方案吗?

  1. Is there a better solution to find growth rate, other than the one above?

如果使用上述公式,是否应该以一些值为参考?还是这也是错误的?

If I use the aforementioned formula, should I take some value as reference? or this is wrong also?

推荐答案

如果需要以百分比显示增长,则习惯上在这些情况下显示[NaN]或类似的内容.另一方面,在这种情况下,增长率将报告为$/month.因此,在您的April示例中,增长率将计算为((20-0)/1.

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?

这篇关于旧值是零时如何计算百分比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆