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.
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.
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.
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.
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.
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.
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:
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
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.
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…
I am away to the races to see if this methodolgy works!
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