# What if you have more than 1 if statement?

**URL:** <https://forum.dynamobim.com/t/what-if-you-have-more-than-1-if-statement/13369>\
**Category:** Revit\
**Created:** [July 21, 2017, 3:14pm UTC](https://forum.dynamobim.com/t/what-if-you-have-more-than-1-if-statement/13369 "2017-07-21T15:14:10Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![ssharma](https://avatars.discourse-cdn.com/v4/letter/s/e19b73/32.png) [@ssharma](https://forum.dynamobim.com/u/ssharma)\
**Post date:** [July 21, 2017, 3:14pm UTC](https://forum.dynamobim.com/t/what-if-you-have-more-than-1-if-statement/13369/1 "2017-07-21T15:14:10Z")

</div>

Hey everyone, ive been looking through the forum for examples on multiple if statements. But, all i could find are one if statement examples. Does anyone know how to do this with nodes or design script?

![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/6/768b2c42c6d3b05258134118742718156d9aa02a.png)

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [July 21, 2017, 4:50pm UTC](https://forum.dynamobim.com/t/what-if-you-have-more-than-1-if-statement/13369/2 "2017-07-21T16:50:21Z")

</div>

Try this code block:

```
a==6?
	"Family 1 Goes Here":
	a==2?
		"Family 2 Goes Here":
		"Family 3 Goes Here";

```

You can go as deep as you like, and remove the quotes to use different families which will become inputs to the node instead of strings.

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/b/0bd27fd016558a35625c5ea126168eb2a31cf37a.PNG)

---

<div class="post-metadata">

**Author:** ![ssharma](https://avatars.discourse-cdn.com/v4/letter/s/e19b73/32.png) [@ssharma](https://forum.dynamobim.com/u/ssharma)\
**Post date:** [July 21, 2017, 5:06pm UTC](https://forum.dynamobim.com/t/what-if-you-have-more-than-1-if-statement/13369/3 "2017-07-21T17:06:56Z")

</div>

Hey Jacob,

Do i just put in the family name where it says “Family 1 Goes Here”? When i remove the quotations i get an error.

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [July 21, 2017, 5:18pm UTC](https://forum.dynamobim.com/t/what-if-you-have-more-than-1-if-statement/13369/4 "2017-07-21T17:18:24Z")

</div>

Post what you did so I can walk you through it. All versions of Dynamo for Revit was uninstalled by IT in my computer last night so unfortunately I can’t do it directly for you.

---

<div class="post-metadata">

**Author:** ![ssharma](https://avatars.discourse-cdn.com/v4/letter/s/e19b73/32.png) [@ssharma](https://forum.dynamobim.com/u/ssharma)\
**Post date:** [July 21, 2017, 5:19pm UTC](https://forum.dynamobim.com/t/what-if-you-have-more-than-1-if-statement/13369/5 "2017-07-21T17:19:58Z")

</div>

HOLY MOLY! if this is what you meant, it worked!!! thank you thank you jacob

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/4/6443caadd29c6baebe540e9d7609b6ceb521c3f9.png)

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [July 21, 2017, 5:25pm UTC](https://forum.dynamobim.com/t/what-if-you-have-more-than-1-if-statement/13369/6 "2017-07-21T17:25:09Z")

</div>

That was it. For speed sake remove the a; b; c; … g; part. The input variable can be called after the fact in this case and it will make things read better and can help with performance on larger graphs too.

---

<div class="post-metadata">

**Author:** ![ssharma](https://avatars.discourse-cdn.com/v4/letter/s/e19b73/32.png) [@ssharma](https://forum.dynamobim.com/u/ssharma)\
**Post date:** [July 21, 2017, 5:30pm UTC](https://forum.dynamobim.com/t/what-if-you-have-more-than-1-if-statement/13369/7 "2017-07-21T17:30:11Z")

</div>

thank you once again!

---

<div class="post-metadata">

**Author:** ![Gcf\_Design](https://avatars.discourse-cdn.com/v4/letter/g/77aa72/32.png) [@Gcf\_Design](https://forum.dynamobim.com/u/Gcf_Design)\
**Post date:** [March 28, 2018, 12:18pm UTC](https://forum.dynamobim.com/t/what-if-you-have-more-than-1-if-statement/13369/8 "2018-03-28T12:18:31Z")

</div>

Hi Jacob.

I have a scenario where a STRING response is required to be returned, depending on whether a value occurs between ranges of values. But l have tried it with IF statements, \<=, \>= etc, but no joy.

Any thoughts on what l am doing wrong?

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/3/d3c619627c43d2997e7ef796d248efa8b740db61.png)

---

<div class="post-metadata">

**Author:** ![Gcf\_Design](https://avatars.discourse-cdn.com/v4/letter/g/77aa72/32.png) [@Gcf\_Design](https://forum.dynamobim.com/u/Gcf_Design)\
**Post date:** [March 28, 2018, 12:21pm UTC](https://forum.dynamobim.com/t/what-if-you-have-more-than-1-if-statement/13369/9 "2018-03-28T12:21:04Z")

</div>

My value is 8.085, therefore l am expecting response ‘b’, but l get “”

---

<div class="post-metadata">

**Author:** ![PauLtus](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/paultus/32/48502_2.png) [@PauLtus](https://forum.dynamobim.com/u/PauLtus)\
**Post date:** [March 28, 2018, 12:22pm UTC](https://forum.dynamobim.com/t/what-if-you-have-more-than-1-if-statement/13369/10 "2018-03-28T12:22:47Z")

</div>

Are you certain all your values are “flattened”?

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [March 28, 2018, 12:47pm UTC](https://forum.dynamobim.com/t/what-if-you-have-more-than-1-if-statement/13369/11 "2018-03-28T12:47:53Z")

</div>

You don’t have a valid conditional statement. You need to use && for a range of values.  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/b/4b080e288a3ca773bf38a2e71832468e0fe15d79.png)

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [March 28, 2018, 12:53pm UTC](https://forum.dynamobim.com/t/what-if-you-have-more-than-1-if-statement/13369/12 "2018-03-28T12:53:12Z")

</div>

Just ask them in sequence - if it’s less than 5.4 then return the first value. If the value wasn’t less than 5.4 but it’s less than 8.5 then your number falls between 5.4 and 8.5. No need to check if it’s \> 5.4 a second time.

That said, the logical statement you couldn’t find is:

`T> 5.4 && T< 8.4`

Though the upper value should likely be a \<= test.

---

<div class="post-metadata">

**Author:** ![Gcf\_Design](https://avatars.discourse-cdn.com/v4/letter/g/77aa72/32.png) [@Gcf\_Design](https://forum.dynamobim.com/u/Gcf_Design)\
**Post date:** [March 28, 2018, 1:31pm UTC](https://forum.dynamobim.com/t/what-if-you-have-more-than-1-if-statement/13369/13 "2018-03-28T13:31:06Z")

</div>

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/c/fc6f2f78813605bb8715067aae04fa224c155ae4.png)

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [March 28, 2018, 6:35pm UTC](https://forum.dynamobim.com/t/what-if-you-have-more-than-1-if-statement/13369/14 "2018-03-28T18:35:34Z")

</div>

You’re still doing 2x the amount of computations here - Only ask something once unless you have a requirement to do it twice. By asking smallest to largest you’ll remove parts from the set sequentially.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/3/d3f7125e7083a168dfbe689ef1a2bc171515a1e0.png)

---

<div class="post-metadata">

**Author:** ![Steven](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/steven/32/112504_2.png) [@Steven](https://forum.dynamobim.com/u/Steven)\
**Post date:** [March 29, 2018, 8:43pm UTC](https://forum.dynamobim.com/t/what-if-you-have-more-than-1-if-statement/13369/15 "2018-03-29T20:43:38Z")

</div>

I am doing something wrong here but I cannot figure it out. Any of you have an Idea?

Edit: _List.Firstitem_ output was a string not a number. Simple _String.ToNumber_ and it works fine now.  
Some times you get drawn into what you are doing and you forget to look at what you have done.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/d/8d8cda217860a260e8eb73dc2a78cb1f1a8a6226.png)

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [March 29, 2018, 10:48pm UTC](https://forum.dynamobim.com/t/what-if-you-have-more-than-1-if-statement/13369/16 "2018-03-29T22:48:41Z")

</div>

What is the Object.Type for “Days”?

By the looks of it, I’d wager it’s not an integer.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/7/47486f59c11a7e614e7b4806156f31a92d845249.png)

---

<div class="post-metadata">

**Author:** ![Steven](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/steven/32/112504_2.png) [@Steven](https://forum.dynamobim.com/u/Steven)\
**Post date:** [March 30, 2018, 1:31am UTC](https://forum.dynamobim.com/t/what-if-you-have-more-than-1-if-statement/13369/17 "2018-03-30T01:31:10Z")

</div>

Ya sorry it was a string. I was zoomed in to much and forgot what the data was.

---

<div class="post-metadata">

**Author:** ![srosenbloomNKA](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/srosenbloomnka/32/110566_2.png) [@srosenbloomNKA](https://forum.dynamobim.com/u/srosenbloomNKA)\
**Post date:** [February 17, 2021, 5:37pm UTC](https://forum.dynamobim.com/t/what-if-you-have-more-than-1-if-statement/13369/18 "2021-02-17T17:37:25Z")

</div>

Hey Jacob,

This worked for me when I just had a _single_ item as the _then_ (i.e. Family 1 Goes Here"). I need a _list_ to be created differently based on the input. When I use the following, it only results in the _first_ item of the list:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/5/b5d7f7645cd1d96bd15202c583fa3ec8c79a737e.png)

Do I have the syntax wrong?

Thanks,  
Scott

Here’s a link to the original post: [What if you have more than 1 if statement? - Revit - Dynamo (dynamobim.com)](https://forum.dynamobim.com/t/what-if-you-have-more-than-1-if-statement/13369/2)

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [February 17, 2021, 6:09pm UTC](https://forum.dynamobim.com/t/what-if-you-have-more-than-1-if-statement/13369/19 "2021-02-17T18:09:22Z")

</div>

If does not utilize the internal lacing mechanisms, so it can’t process variable depth lists. Instead separate the single output into two or three.  
First have your if statement return an index number as a new variable, then build a list of all your desired values, and then pull the resulting set from the list.

Looks like this:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/9/49bed8422d777a1a2accc67455af0af64d4dc1b2.png)

---

<div class="post-metadata">

**Author:** ![Steven](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/steven/32/112504_2.png) [@Steven](https://forum.dynamobim.com/u/Steven)\
**Post date:** [February 17, 2021, 6:37pm UTC](https://forum.dynamobim.com/t/what-if-you-have-more-than-1-if-statement/13369/20 "2021-02-17T18:37:40Z")

</div>

I think @jacob.small nailed it. I started to give it a try before he posted and then continued for my own benefit. Thanks, for the clean solution Jacob.

Failed solution 1:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/e/aeec7acf249d356cfc4edc224f598668983fb82b.png)

Failed solution 2 (Basically the same as above):

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/6/d634ad3fee6bd60a30065c6590f17ec1b70b06c3.png)

Working solution (same concept as Jacobs):

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/a/3aece5ad64d0a21f37991833b365c064cbdc728c.png)

It looks like the new if node will be able to accommodate this function.

> [@\[Request for Feedback\] If Node](https://forum.dynamobim.com/t/request-for-feedback-if-node/45257/23):
>
> Hello followers of this thread! We are now actively developing a new If node and we would like to gather feedback on how it’s working, whether it meets all the needs expressed in this thread and beyond and if the node needs Lacing and List@Level or not; the reason we are trying to avoid that case at present is that we are currently unified with DesignScript and this would deviate from the output. Currently, the nod has the following kinds of results:

[Next page](https://forum.dynamobim.com/t/what-if-you-have-more-than-1-if-statement/13369.md?page=2)
