# Four answers in one formula?

#### bpflyr

##### Board Regular
Sorry, I just posted a question very similar to this, but I had not thought it all the way through. Here's what I'm trying to do in one formula:

IF LEN(J138)=0, then return F138
IF LEN(J138)>0, then SUM(E138-J138). IF that result is 0, then be blank.
IF LEN(F138)=0, then be blank

Thank you!!

### Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

#### nbrcrunch

##### Well-known Member

You almost wrote out verbatim what the formula would look like.

=if(len(f138)=0,"",if(len(J138)=0,F138,if(len(J138)>0,sum(E138:J138),"")))

the basic construct of IF in Excel is:

IF(condition, true-result, false-result)

You can "nest" up to 6 or 7 different IF statement. (Forget the actual number).

#### Norie

##### Well-known Member
bpflyr

Could you try and stick to 1 thread?

I know this one is slighty different but they are related.

#### Yogi Anand

##### MrExcel MVP
Hi bpflyr:

It is not a good idea to start another thread on the same type of question. Anyway, how about ...

=IF(F138=0,"",IF(LEN(J138)=0,F138,IF(E138-J138,E138-J138,"")))

##### MrExcel MVP
bpflyr said:
Sorry, I just posted a question very similar to this, but I had not thought it all the way through. Here's what I'm trying to do in one formula:

IF LEN(J138)=0, then return F138
IF LEN(J138)>0, then SUM(E138-J138). IF that result is 0, then be blank.
IF LEN(F138)=0, then be blank

Thank you!!

=IF(J138="",IF(F138="","",F138),IF(E138-J138,E138-J138,""))

bpflyr

Replies
4
Views
59
Replies
6
Views
113
Replies
11
Views
151
Replies
1
Views
190
Replies
6
Views
210