# IF Statement Issue

**URL:** <https://forum.dynamobim.com/t/if-statement-issue/78672>\
**Category:** Lists-Logic\
**Tags:** dynamo\
**Created:** [July 14, 2022, 10:17am UTC](https://forum.dynamobim.com/t/if-statement-issue/78672 "2022-07-14T10:17:53Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![denistikhon](https://avatars.discourse-cdn.com/v4/letter/d/54ee81/32.png) [@denistikhon](https://forum.dynamobim.com/u/denistikhon)\
**Post date:** [July 14, 2022, 10:17am UTC](https://forum.dynamobim.com/t/if-statement-issue/78672/1 "2022-07-14T10:17:53Z")

</div>

Why does one format of one result depend on another?  
Can somebody explain to me what’s going on with IF statement?

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

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [July 14, 2022, 10:27am UTC](https://forum.dynamobim.com/t/if-statement-issue/78672/2 "2022-07-14T10:27:14Z")

</div>

From what I recall about this the reason you’ve only got 6 outputs in the bottom left is because of lacing.

The IF node isn’t great and it’s seeing that the false only has 6 outputs, so it only gives you 6 even though it’s true. 😑

Have you tried the scope IF node instead or doing it with designscript?

Personally often do this with Python.

---

<div class="post-metadata">

**Author:** ![bvs1982](https://avatars.discourse-cdn.com/v4/letter/b/43a26b/32.png) [@bvs1982](https://forum.dynamobim.com/u/bvs1982)\
**Post date:** [July 14, 2022, 11:39am UTC](https://forum.dynamobim.com/t/if-statement-issue/78672/3 "2022-07-14T11:39:28Z")

</div>

You’re right. It is also explained [here](https://forum.dynamobim.com/t/limited-list-size-while-using-if-statement/75891).

That being said you can find a solution (workaround) [here](https://forum.dynamobim.com/t/if-statement-output/8134/9).

> [@If - Statement Output](https://forum.dynamobim.com/t/if-statement-output/8134/10):
>
> Another clever way I found on github ([https://github.com/DynamoDS/Dynamo/issues/6491](https://github.com/DynamoDS/Dynamo/issues/6491))[image]

---

<div class="post-metadata">

**Author:** ![kslifter](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kslifter/32/192657_2.png) [@kslifter](https://forum.dynamobim.com/u/kslifter)\
**Post date:** [July 14, 2022, 1:15pm UTC](https://forum.dynamobim.com/t/if-statement-issue/78672/4 "2022-07-14T13:15:43Z")

</div>

You might try the if/then/else node from Crumple Package. He made it through Python.

---

<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:** [July 14, 2022, 1:44pm UTC](https://forum.dynamobim.com/t/if-statement-issue/78672/5 "2022-07-14T13:44:59Z")

</div>

This question comes up all the time. @Alien already answered the why, but if you want more info you can just search the forum for some more in depth explanations.

Later versions of Dynamo have corrected this with an updated If node that accepts lacing and list levels while also defaulting to the expected outcome of returning entire lists.

For versions that still use this old node the easiest solution is to use the code block workaround.

```auto
i = test ? 0 : 1;
[ifTrue, ifFalse][i];

```

This workaround merges your `true` and `false` lists into a a single list at indices 0 and 1 respectively. The `test` condition then returns either index 0 or 1 based on the results and then gets the sublist at that index, ensuring that you get the entire list.

---

<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 14, 2022, 5:17pm UTC](https://forum.dynamobim.com/t/if-statement-issue/78672/6 "2022-07-14T17:17:01Z")

</div>

Note that current builds include a version of the if node which allows for replication and lacing as per any other node.

---

<div class="post-metadata">

**Author:** ![bvs1982](https://avatars.discourse-cdn.com/v4/letter/b/43a26b/32.png) [@bvs1982](https://forum.dynamobim.com/u/bvs1982)\
**Post date:** [July 14, 2022, 5:58pm UTC](https://forum.dynamobim.com/t/if-statement-issue/78672/7 "2022-07-14T17:58:31Z")

</div>

@jacob.small

Since which build?

---

<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 15, 2022, 1:41am UTC](https://forum.dynamobim.com/t/if-statement-issue/78672/8 "2022-07-15T01:41:18Z")

</div>

It’s definitely in 2.13, but it may have been 2.12.
