IF statement protocol

Dynamic Components make use of spreadsheet formulae. But not all spreadsheets seem to accept the same terminology for logical functions.

What I want to do is to say “If x is greater than y and less than z, return 1”. Some advice is to use nested IF statements. Others use the AND operator.

This forum is populated by clever bods who will know the answer to how best to do it in DCs without even thinking about it. I hope to hear from them.

If there’s more than one condition, AND is simpler and less prone to error with all those commas and brackets.


IF-AND-DC.skp (19.6 KB)

1 Like

That looks really helpful.

I see from the DC you made that you have split it up into two separate conditions (although I think the second may be incomplete?). What does the first return?

Just to up the ante a bit, I am trying to make a DC that would create a casement window. Standard windows in the UK have given widths and you usually select according to that. So I want the user defined entry to have a list of those widths (488mm, 630, 915, etc). If someone chooses the smaller ones, it means it’s a single casement and the DC will then create the frame and sash elements to suit. But if they choose a middle size, it will create a two sash window. Larger still and it becomes three sashes wide. You can see that for the smaller ones, I just need the IF statement to test if it is smaller than 650 (say). But the two sash one needs two conditions, greater than 630 and less than 1210. It’s the formula for this one that I am sweating over.

There’s two conditions: one for IF, one for AND. Scale the cube to see them evaluating to 0 or 1.If you scale the cube so it’s x length is between the y and z, it’ll return 1. You’d have to scale the z up a bit first so it’s the biggest one.

You need to clearly define the problem first. You have an overlap where it’s one sash for less than 650 and more than 630 gives two sashes. If the user is choosing from a list, then it’s more predictable, you’ll know all the options they can choose.

The IF statement is probably the easiest part of this, it would be the same as the above post, replacing LenX, LenY, LenZ with width, 630, 1210 respectively.