简体   繁体   中英

How to use "if statement" in a formula?

Amount Payment model
100 Yearly
6 Monthly

In the 3rd column, I wish to introduce a formula which will automatically read the entry in column "Payment Model". 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.

Thanks in advance

Tried using the "if" statement, its not working. Here is my formula: =IF($B2 == "Yearly",$A2*1,$A2*12)

Throws me a Formula error everytime.

Excel does not use the double equals.
The formula you want, provided by Mayukh Bhattacharya and BigBen :

=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. Note that the comparison is done via the = operator.

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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