# If function giving wrong answer

1. ## If function giving wrong answer

=IF(AW5>T5,"B",IF(AW5=T5,"G",IF(T5-AW5=1,"A",IF(T5-AW5>=2,"R"))))

Using the formula above I'm getting B show up in places it shouldn't. I'm quite new to this so could be missing something very obvious!  Register To Reply

2. ## Re: If function giving wrong answer

Welcome to the forum. Sorry - can't tell from the formula what might be wrong. Do you have text values that are being treated as numbers? If so, try this:

=IF(AND(ISNUMBER(AW5),AW5>T5),"B",IF(AW5=T5,"G",IF(T5-AW5=1,"A",IF(T5-AW5>=2,"R"))))

There are instructions at the top of the page explaining how to attach your sample workbook.

A good sample workbook has just 10-20 rows of representative data that has been desensitised. It also has expected results mocked up, relevant cells highlighted and a few explanatory notes.  Register To Reply

3. ## Re: If function giving wrong answer

Hi - thanks for the quick response.

It's part of a huge spreadsheet where AW depends on the outcome of 5 other cells so I'm struggling to attach. I've attached a picture for now while I figure it out

The formula you gave me above returns the correct result in some cells, but others change to FALSE

Capture.PNG  Register To Reply

4. ## Re: If function giving wrong answer

A good sample workbook has just 10-20 rows of representative data that has been desensitised. It also has expected results mocked up, relevant cells highlighted and a few explanatory notes.
I can't work with a picture, but if that first criterion is returning "B", then either the value in T or the one in AW is text (or both are).  Register To Reply

5. ## Re: If function giving wrong answer

Try this:

=IF(AW5-T5>0,"B",IF(AW5-T5=0,"G",IF(T5-AW5=1,"A","R")))  Register To Reply

6. ## Re: If function giving wrong answer

Thank you - this worked!

The values in T are mostly imported from elsewhere. Those that were typed in manually were the ones giving incorrect results.  Register To Reply

7. ## Re: If function giving wrong answer

Also, if you have not already done so, you may not be aware that you can thank those who have helped you by clicking the small star icon (* Add Reputation) located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of all those who offered help.  Register To Reply