# Multiple IFs in no code formula?

**URL:** <https://community.weweb.io/t/multiple-ifs-in-no-code-formula/3418>\
**Category:** Ask us anything\
**Created:** [July 7, 2023, 10:29am UTC](https://community.weweb.io/t/multiple-ifs-in-no-code-formula/3418 "2023-07-07T10:29:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![raelyn](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/raelyn/32/2803_2.png) [@raelyn](https://community.weweb.io/u/raelyn)\
**Post date:** [July 7, 2023, 10:29am UTC](https://community.weweb.io/t/multiple-ifs-in-no-code-formula/3418/1 "2023-07-07T10:29:42Z")

</div>

I have a button text that I want to change according to the status of a variable.

If status = A, I want the text to show “text A”.  
If status = B, I want the text to show “text B”  
If status is anything else, I want the text to show “text C”.

How do I do this?

I’m trying to use the “IF” no code formula but I can only make it such that if it’s A, show text A, if its everything else, show text C. but the system doesn’t take into account B. I’ve also tried having “and” between 2 IF statements which I thought was working but it doesn’t show correctly too.

What formula should I be using for “multiple if” conditions?

---

<div class="post-metadata">

**Author:** ![jaredgibb](https://avatars.discourse-cdn.com/v4/letter/j/ecd19e/32.png) [@jaredgibb](https://community.weweb.io/u/jaredgibb)\
**Post date:** [July 7, 2023, 11:11am UTC](https://community.weweb.io/t/multiple-ifs-in-no-code-formula/3418/2 "2023-07-07T11:11:48Z")

</div>

![Screen Shot 2023-07-07 at 7.09.50 AM](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/3/3c1eba4407327137c1039a8c7990a573624c5be4.png)  
😂 😭

the [switch case](https://docs.weweb.io/formulas/conditional.html#switch) would be more preferable but it doesnt seem to have the default condition like a [normal switch operator](https://www.w3schools.com/js/js_switch.asp) would.

 ![Screen Shot 2023-07-07 at 7.13.43 AM](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/5/560fe929b2fa9ee32d51321292aceaaa906c3bb9.png)  
from my point of view, i’d use javascript for this \* because\* it’s a simple operation and the no-code method doesnt allow for this easily. I suppose you could create a variable that is for that text element. when an option is updated int he app, you could use the multi-option split operation and set a variables value to display accordingly  
 ![Screen Shot 2023-07-07 at 7.15.13 AM](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/d/d72e905b6a8d9af07fdbce58f86e1440abf0b3c7.png)

---

<div class="post-metadata">

**Author:** ![raelyn](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/raelyn/32/2803_2.png) [@raelyn](https://community.weweb.io/u/raelyn)\
**Post date:** [July 7, 2023, 4:10pm UTC](https://community.weweb.io/t/multiple-ifs-in-no-code-formula/3418/3 "2023-07-07T16:10:06Z")

</div>

Oo, thank you. I will give the multi split option a try. 😁

---

<div class="post-metadata">

**Author:** ![Alexis](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/alexis/32/13248_2.png) [@Alexis](https://community.weweb.io/u/Alexis)\
**Post date:** [July 7, 2023, 4:14pm UTC](https://community.weweb.io/t/multiple-ifs-in-no-code-formula/3418/4 "2023-07-07T16:14:23Z")

</div>

> the [switch case](https://docs.weweb.io/formulas/conditional.html#switch) would be more preferable but it doesnt seem to have the default condition like a [normal switch operator](https://www.w3schools.com/js/js_switch.asp) would.

You can use the switch and add `or yourDefaultValue` to achieve the same 🙂

 ![Capture d’écran 2023-07-07 à 18.14.12](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/9/9b48f65cb375486850a4c7548049dfe80b3307a5.png)

Edit : But be careful, if one of your value is falsy (0, “”, null, false), it will return the defaultValue instead, so you can do that trick only if you have no falsy values in your switch

---

<div class="post-metadata">

**Author:** ![raelyn](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/raelyn/32/2803_2.png) [@raelyn](https://community.weweb.io/u/raelyn)\
**Post date:** [July 18, 2023, 2:01am UTC](https://community.weweb.io/t/multiple-ifs-in-no-code-formula/3418/5 "2023-07-18T02:01:01Z")

</div>

Hey Alexis! What if it’s a multiple IF PLUS contains formula is needed?

I have a slug, [url.com/cows](http://url.com/cows), [url.com/dogs](http://url.com/dogs), [url.com/cats](http://url.com/cats), [url.com/cowpoop](http://url.com/cowpoop), [url.com/](http://url.com/) dogbones

So if URL contains “cow”, I want it to return 1.  
If URL contains “dog”, I want it to return 2.  
If URL does not contain either, I want it to return 3 as default value.

---

<div class="post-metadata">

**Author:** ![Alexis](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/alexis/32/13248_2.png) [@Alexis](https://community.weweb.io/u/Alexis)\
**Post date:** [July 18, 2023, 10:28am UTC](https://community.weweb.io/t/multiple-ifs-in-no-code-formula/3418/6 "2023-07-18T10:28:28Z")

</div>

You can try to create your own switch formula by embedding multiple successive if

```auto
if
else
  if
  else
    if
    else
if(contain(myVar, "cow"), 1, if(contain(myVar, "dog", 2, 3))

```
