PDA

View Full Version : Excel formula IF function


AJC_50
Oct 4, 2007, 01:57 PM
Hi.
I am creaing a spreadsheet for work. Basically I have a column that shows all the project names, it shows a date and a price for the project.
I need this price to then be automatically placed into the appropriate monthly column.
I.e if the project is 20,000 and happened on the 21st of jan 2007 then the 20000 gets put into the jan 2007 column.
I have figured out how to get the formula to work. But I have one small problem with it. If the month is does not match the January column then it displays as 0 which is correct but if the year is different then it says False instead. I need it so that instead of false it also says 0.

The formula I have is
=IF(YEAR(E17)=2007,IF(MONTH(E17)=1,SUM(D17),0))

so if the project is in January 2007 then the price which is in cell D17 will be displayed.

Many Thanks

ebaines
Oct 4, 2007, 02:21 PM
Change the last part of the formula to look like this:

... (D17),0),0)

Note that I added ",0" just in front of the last paren. This way if the cell E17 is not 2007, it will show a 0. Since you hadn't specified what to do in case E17 is not 2007, the spreadsheet showed "FALSE"

KISS
Oct 4, 2007, 02:34 PM
It's going to do that.

IF(logical_test,value_if_true,value_if_false)


Your test is OK, but the value_if_true is another test

If you typed =If(Month(E17)=1) in a cell, it will return TRUE or FALSE hence this is what is being displayed.

Write a second IF statement for argument #2 that has 3 arguments.
The test, the value if the test is true and the value when the test is false.

There is more here than meets the words and I'm missing it.