简体   繁体   English

如何在公式中使用“if 语句”?

[英]How to use "if statement" in a formula?

Amount数量 Payment model支付模式
100 100 Yearly每年
6 6个 Monthly每月

In the 3rd column, I wish to introduce a formula which will automatically read the entry in column "Payment Model".在第 3 栏中,我想介绍一个公式,它会自动读取“支付模式”栏中的条目。 If the entry is, "Yearly" it will just copy the value from column "Amount".如果条目是“每年”,它只会复制“金额”列中的值。 If the entry is, "Monthly" it will multiply the value with 12.如果条目是“每月”,它会将值乘以 12。

Thanks in advance提前致谢

Tried using the "if" statement, its not working.尝试使用“if”语句,它不起作用。 Here is my formula: =IF($B2 == "Yearly",$A2*1,$A2*12)这是我的公式: =IF($B2 == "Yearly",$A2*1,$A2*12)

Throws me a Formula error everytime.每次都给我一个公式错误。

Excel does not use the double equals. Excel 不使用双等号。
The formula you want, provided by Mayukh Bhattacharya and BigBen :你想要的公式,由Mayukh BhattacharyaBigBen提供:

=IF($B2="Yearly",$A2*1,$A2*12)

This is the solution:这是解决方案:

=$A2 * IF($B2="Monthly", 12, 1)

We need $A2 anyway and we use the IF to determine what to multiply it with.无论如何我们都需要$A2并且我们使用IF来确定将它与什么相乘。 Note that the comparison is done via the = operator.请注意,比较是通过=运算符完成的。

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM