Nested If and Then Statement Returns the first value all the time

Hi there, I have managed to create a nested formula without an error, but for an unknown reason, it always returns the value of the first If. Can anyone please help me? Perhaps the format is incorrect?



It seems to me that #A_SS_Spread is the 1st condition that is being met, so it doesn’t need to look further. If you have all of the variables in the variables table, then it will only look until it finds 1 that matches the condition. If you remove the #A_SS_Spread from the variables, then it will find the #B… and use it. I think that you need to 0 the formulas at the unused cup sizes and only enter a formula in the one that you’re using. Check if that will work for you.

In a case similar to this that I had, I copied & pasted the formula into the Description field so that I could 0 the formula, but when I needed to use it later, I could copy & paste the formula back into the Formula field & 0 the other.

1 Like

Hi Grace, no, it must be something else. If I change the source so that the correct response is C, it still returns the answer for A. The same for A, B, C, D, DD. The answer is always for A.

I also tried to add zero to the end of the formula and the same thing still happens.

Any more ideas?

Thank you for your help,



Can you send me the pattern & measurement file so that I can look & see?

You can PM them to me, if you wish.

1 Like

If this line exists in the pattern then it will also stop on this line. So if you 0 both this line & the variable, it will still use the formula that follows and look no further.

Aaaahhh… I think I’ve got it…

It doesn’t like the = sign.

(Line_Adj_Cup_Spread_DD_Cup>#D_Spread?#DD_SS_Spread: (Line_Adj_Cup_Spread_DD_Cup>#C_Spread?#D_SS_Spread: (Line_Adj_Cup_Spread_DD_Cup>#B_Spread?#C_SS_Spread: (Line_Adj_Cup_Spread_DD_Cup>#A_Spread?#B_SS_Spread: #A_SS_Spread))))

So what you have to do is start with the largest size and say “if it’s larger than the 2nd to largest size, then use this one or if it’s larger than the 2nd to largest size then use that one, etc. etc., otherwise use the smallest size”


I think I made a bit of a mistake in my formula, but that’s the idea.

1 Like

Hi Grace, I’m sorry you were up so late! I hope you got a good sleep!

I thought you were on to something; however I have not found a solution yet. I’m about to give up. There must be something else - is there a format or operation that I’m missing? Is there a limit?

The closest I can come to is when we use < (not > or =). I tested all of the values and some are correct, but some are incorrect. I can’t see a pattern that could highlight where the error is. I also changed the varable value to be non-negative but that wasn’t it either.

This is what I last used. The result for DD and A are the only ones correct.


1 Like

Hi, thanks, yes, I slept well.

On mine, it works very well for all except the C. Somewhere in my journeys, I noticed that the C line length was returning a value of 1.2702. This will make it larger than 1.27 and therefore put it into D. I just want to check what I can do about that.

Be back shortly.

I would need to see the pattern and measurments.

It’s a C++ thing… = is “assignment”, == is “equal”. You use = to assign a value: variableA = 10… you use if(variableA == 10) then… blah blah.

So ((Line_Adj_Cup_Spread_DD_Cup=#A_Spread)?#A_SS_Spread:((Line_Adj_Cup_Spread_DD_Cup=#B_Spread)?#B_SS_Spread:((Line_Adj_Cup_Spread_DD_Cup=#C_Spread)?#C_SS_Spread:((Line_Adj_Cup_Spread_DD_Cup=#D_Spread)?#D_SS_Spread:#DD_SS_Spread))))

Is doing nothing but assigning… it’s not testing for equal. Try using:


I found it, I found it!!!

It has to do with the negative values. The new formula works with C, D & DD but doesn’t work with A & B. This is because those 2 have negative values in the Variables table formulas, which go into a line (which adjusts perfectly), but after that, the line length is used, which then gets used in the If, Then, Else. The line length is then the same value as the negative value, but then it becomes a positive value and this is why it isn’t working for those 2 sizes.

I just need to figure out how to get those to reflect a negative value & then it’ll work :wink:

Again… just try using the == to test for equal.

By using the == it pruduces this logic:

if (Line_Adj_Cup_Spread_DD_Cup == #A_Spread) { return #A_SS_Spread; }

else if (Line_Adj_Cup_Spread_DD_Cup == #B_Spread) { return #B_SS_Spread; }

else if (Line_Adj_Cup_Spread_DD_Cup == #C_Spread) { return #C_SS_Spread; }

else if (Line_Adj_Cup_Spread_DD_Cup == #D_Spread) { return #D_SS_Spread’; }

return #DD_SS_Spread;

1 Like

Yes… because the egual opertator is == not the assignment operator =. By using the = you are assigning Line_Adj_Cup_Spread_DD_Cup to the value of #A_Spread which is going to result in a True, and thus it choses the 1st value. Use the == and it will probably work.

1 Like

LS again. Quickly before the internet goes out…

(Line_Enter_Cup_Size_Cup_Spread-Line_Enter_Spread_Cup_Spread)>(#D_Spread+0.003)?#DD_SS_Spread: (Line_Enter_Cup_Size_Cup_Spread-Line_Enter_Spread_Cup_Spread)>(#C_Spread+0.003)?#D_SS_Spread: (Line_Enter_Cup_Size_Cup_Spread-Line_Enter_Spread_Cup_Spread)>(#B_Spread+0.003)?#C_SS_Spread: (Line_Enter_Cup_Size_Cup_Spread-Line_Enter_Spread_Cup_Spread)>(#A_Spread+0.003)?#B_SS_Spread: #A_SS_Spread

This formula now works perfectly.

You need to change the formula at Adj_Cup_Spread: Line_Enter_Cup_Size_Cup_Spread-Line_Enter_Spread_Cup_Spread

Sorry LS caught me.

Ah! Thank you very much for that == tip. I didn’t know that. :star_struck:

Hi Grace!

Fantastic! You are a star! It works 2 ways. I tested both. Who would know we needed “==” for equal? I just rechecked the seamly2d manual to see if I missed it. The version I saved to my computer doesn’t even mention equals as an option…:slight_smile:

I am away to the races to see if this methodolgy works!

Thank you so much!



:rofl: :rofl: :rofl: Yes, I know it’s not in the manual. Otherwise I’d have used it ages ago.

You’re very welcome. And I always learn a lot from figuring things out like this. And thanks to @Douglas for the == tip.


Hi Douglas, I wanted to thank you for your help on my nested IF formula. It was a success!



Yes, thank you for Douglas. He has been very helpful. What a great resource you both provide.



Like I said… it’s a c++ thing. The math parser muparser that qmuparser in the app is based on is a c++ library, so that’s why it adheres to the c++ binary operators. It catches me every once in awhile where I’ll forget the ==. Thing is the complier will catch the error as you can’t use an assigment in an if clause… unlike in the qmuparser