Bruce Kieffer Posted March 13, 2021 Share Posted March 13, 2021 (edited) How do I write an if/then formula for a worksheet? I think I found it. if ((logical_test), value_if_true, value_if_false) OK, but I can't make sense of how it is used. Can you help? Here's an example of what I want. if cell D2 = width, 2, 10 Edited March 13, 2021 by Bruce Kieffer Quote Link to comment
Jesse Cogswell Posted March 13, 2021 Share Posted March 13, 2021 Testing on VW2019, your formula would look like the following: =IF((D2='Width'),2,10) If you're familiar with Excel, what's a little different is the extra set of parentheses around the logical test. If you miss this, the result will simply by TRUE or FALSE depending on the logical test and it will reformat the formula to remove the IF statement. Quote Link to comment
Bruce Kieffer Posted March 13, 2021 Author Share Posted March 13, 2021 @Jesse Cogswell Thanks. I found a post from 2018 of the support board last night that showed me pretty much the same as what you show and I got it working. Next step for me is to make a nested if/then formula. I'm working on that now. I do wish the Vectorworks help showed a better example of the if/then, but it shows something that made zero sense to me. Quote Link to comment
Bruce Kieffer Posted March 13, 2021 Author Share Posted March 13, 2021 (edited) I'm stuck trying to work out a nested if/then formula. Here's what I need to combine: =IF((D2=WIDTH), MIN(HEIGHT, LENGTH), MIN(LENGTH, WIDTH)) and =IF((D2=LENGTH), MIN(WIDTH, HEIGHT), MIN(LENGTH, WIDTH)) Or in human language! If D2 = WIDTH then show the minimum of HEIGHT and LENGTH, otherwise if D2 = LENGTH then show the minimum of HEIGHT and WIDTH. Using OR might be a solution too. Edited March 13, 2021 by Bruce Kieffer Quote Link to comment
Pat Stanford Posted March 14, 2021 Share Posted March 14, 2021 What are Width and Length? Values in a cell? If so, then they need to be compared as strings. =IF((D2='WIDTH'), Min(HEIGHT, LENGTH), Min(Length,Width)) If they are numeric values, then your equals will fail unless they are equal out to 16 decimal places. You probably want to round to maybe two or three places to give the equals a better chance of working. Quote Link to comment
Bruce Kieffer Posted March 14, 2021 Author Share Posted March 14, 2021 56 minutes ago, Pat Stanford said: What are Width and Length? Values in a cell? If so, then they need to be compared as strings. They are Vectorworks functions. Quote Link to comment
Bruce Kieffer Posted March 14, 2021 Author Share Posted March 14, 2021 I see no way to make an "OR" formula, so I'm back to needing a nested if/then. Is it possible? Quote Link to comment
Pat Stanford Posted March 14, 2021 Share Posted March 14, 2021 If you are combining multiple logical statements, then an ampersand ("&") is used for an AND condition and a vertical pipe character ("|") [on my Mac keyboard this is the shifted option for the forward slash character, right side of the keyboard, over the Return key] is use for an OR condition. ((A=B) & (C=D)). A equals B AND C equals D ((A=B) | (C=D)). A equals B OR C equals D Quote Link to comment
Bruce Kieffer Posted March 15, 2021 Author Share Posted March 15, 2021 I'm experimenting since I can't seem to find any Vectorworks documentation explaining more complex formula functions. I cannot make "or" work in my formula. I get results, but they are not correct. I did find a way to write a nested if/then and it works. =IF((D2=WIDTH), MIN(HEIGHT, LENGTH), IF((D2=HEIGHT), MIN(WIDTH, LENGTH), MIN(WIDTH, HEIGHT))) This returns the middle value of the three values, which would be SO MUCH EASIER to do if only Vectorworks had a MEDIAN function. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.