# Nested IF enigma.

1. ## Nested IF enigma.

The below nested if function works:

=IF(O4<5,IF(O4=1,IF(SUM(LEN(D4)-LEN(SUBSTITUTE(D4,"p","")))>1,K4/SUM(LEN(D4)-LEN(SUBSTITUTE(D4,"p","")))*L4/H4,L4/H4),G4*K4/H4),"N/A")

When I substitute the below if function in the "false" segment of the If len >1

IF(L4>0,L4/H4,"No YTD")

to get:

=IF(O4<5,IF(O4=1,IF(SUM(LEN(D4)-LEN(SUBSTITUTE(D4,"p","")))>1,K4/SUM(LEN(D4)-LEN(SUBSTITUTE(D4,"p","")))*L4/H4,IF(L4>0,L4/H4,"No YTD"),G4*K4/H4),"N/A")

I get the too many arguments error.

I've messed with it too long now and can't see the forest for the trees.

Any help appreciated.

2. ## Re: Nested IF enigma.

Maybe just move one of the closed brackets:

=IF(O4<5,IF(O4=1,IF(SUM(LEN(D4)-LEN(SUBSTITUTE(D4,"p","")))>1,K4/SUM(LEN(D4)-LEN(SUBSTITUTE(D4,"p","")))*L4/H4,IF(L4>0,L4/H4,"No YTD",G4*K4/H4)),"N/A")

Hope this helps.

Pete

3. ## Re: Nested IF enigma.

Thanks Pete, but still "too many arguments"

4. ## Re: Nested IF enigma.

May be you missed a bracket:
=IF(O4<5,IF(O4=1,IF(SUM(LEN(D4)-LEN(SUBSTITUTE(D4,"p","")))>1,K4/SUM(LEN(D4)-LEN(SUBSTITUTE(D4,"p","")))*L4/H4,IF(L4>0,L4/H4,"No YTD")),G4*K4/H4),"N/A")

5. ## Re: Nested IF enigma.

Okay, well splitting it up and putting in then and else and colour-coding it, you have this:

=IF(O4<5, then

IF(O4=1, then

IF(SUM(LEN(D4)-LEN(SUBSTITUTE(D4,"p","")))>1, then K4/SUM(LEN(D4)-LEN(SUBSTITUTE(D4,"p","")))*L4/H4, else

IF(L4>0,L4/H4, then "No YTD", else G4*K4/H4)),

else "N/A")

You can see that the first IF has no matching else or closed bracket.

Hope this helps.

Pete

6. ## Re: Nested IF enigma.

Thanks bebo for the solution
and thanks Pete for the diagnostics, I was stumbling for a form of trouble shooting and your answer helps me.

##### Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1