# Improved If functionality

**URL:** <https://connect.superhuman.com/t/improved-if-functionality/1599>\
**Category:** Product Feedback\
**Created:** [July 19, 2018, 1:20am UTC](https://connect.superhuman.com/t/improved-if-functionality/1599 "2018-07-19T01:20:59Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![cnr](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/cnr/32/24174_2.png) [@cnr](https://connect.superhuman.com/u/cnr)\
**Post date:** [July 19, 2018, 1:20am UTC](https://connect.superhuman.com/t/improved-if-functionality/1599/1 "2018-07-19T01:20:59Z")

</div>

Right now, there’s a pattern I would like to be able to use with the If function that I cannot seem to do. The pattern is this:

Let’s say have a Variable I want to test with a conditional. For simplicity, let’s say `Variable = 1.`

The way to test a conditional is with `If(Variable>0, true, false)`

But I often want to invoke Coda’s special chaining like:  
`Variable.If(>0, true, false)`

I’d also like to be able to return the value of the Variable with:  
`Variable.If(>0, Value, false)`

This second part could be especially useful when Variable is something really convoluted like a long formula.  
My pattern right now is:  
`If(ReallyLongFormula.isBlank(), ReallyLongFormula, "Some text")`

Instead it could be:  
`ReallyLongFormula.If(Value.IsBlank(), Value, "Some text")`

This might not seem like much, but imagine a formula like this needing to be used twice:  
`[Unit Actions].[Unit Type].Unique().FormulaMap(If(CurrentValue.In(Units.[Unique Unit Name].Unique()).Not(),CurrentValue,"-")).Split(",")`

(btw, I may be using the attribute `Value` wrong, and in that case just mentally replace it with a better name like `self` or whatever)

You can’t do this with Filter() without using additional named variables, or if you can I don’t know how.

---

<div class="post-metadata">

**Author:** ![Al\_Chen\_Coda](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/al_chen_coda/32/5588_2.png) [@Al\_Chen\_Coda](https://connect.superhuman.com/u/Al_Chen_Coda)\
**Post date:** [July 21, 2018, 12:34am UTC](https://connect.superhuman.com/t/improved-if-functionality/1599/2 "2018-07-21T00:34:23Z")

</div>

Hey @cnr, I hear what you’re saying. This is similar to how `IFERROR()` work in Excel, where the formula could be shortened by something like this: `IFERROR(ReallyLongFormula, "Some Text")`. This doesn’t account for values \<= 0, unfortunately.

The workaround for me (in Coda) is simply giving the long formula a name so that you can reference that name in the `IF()` function:

 ![12%20PM](https://global.discourse-cdn.com/coda1/original/2X/b/b4c5864f4ff7f448b8a4fcc1e00748c7e846854a.png)

---

<div class="post-metadata">

**Author:** ![Samuel\_Davenport](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/samuel_davenport/32/3512_2.png) [@Samuel\_Davenport](https://connect.superhuman.com/u/Samuel_Davenport)\
**Post date:** [December 2, 2018, 9:07pm UTC](https://connect.superhuman.com/t/improved-if-functionality/1599/3 "2018-12-02T21:07:11Z")

</div>

Hi @Al_Chen_Coda, I think this would be a really useful reminder for new folks like me, but unfortunately the screenshot is now dead. Is there a chance you could refresh it?  
Thanks!

---

<div class="post-metadata">

**Author:** ![Al\_Chen\_Coda](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/al_chen_coda/32/5588_2.png) [@Al\_Chen\_Coda](https://connect.superhuman.com/u/Al_Chen_Coda)\
**Post date:** [December 3, 2018, 2:49am UTC](https://connect.superhuman.com/t/improved-if-functionality/1599/4 "2018-12-03T02:49:42Z")

</div>

@Samuel_Davenport Sure thing just re-uploaded the image, not sure why it disappeared. Let me know if you have any questions!

---

<div class="post-metadata">

**Author:** ![Loi\_Quang\_Ho](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/loi_quang_ho/32/5900_2.png) [@Loi\_Quang\_Ho](https://connect.superhuman.com/u/Loi_Quang_Ho)\
**Post date:** [April 24, 2019, 4:54pm UTC](https://connect.superhuman.com/t/improved-if-functionality/1599/5 "2019-04-24T16:54:17Z")

</div>

@Al_Chen_Coda

I have met the same situation and i think about iferror() in Excel.  
Now, could I give the long formula a name in new update of coda ?

---

<div class="post-metadata">

**Author:** ![Al\_Chen\_Coda](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/al_chen_coda/32/5588_2.png) [@Al\_Chen\_Coda](https://connect.superhuman.com/u/Al_Chen_Coda)\
**Post date:** [April 24, 2019, 8:31pm UTC](https://connect.superhuman.com/t/improved-if-functionality/1599/6 "2019-04-24T20:31:53Z")

</div>

Hi @Loi_Quang_Ho, yes you could always give formulas in Coda a name. See this [help article](https://help.coda.io/formulas/named-formulas) for more info.

---

<div class="post-metadata">

**Author:** ![Loi\_Quang\_Ho](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/loi_quang_ho/32/5900_2.png) [@Loi\_Quang\_Ho](https://connect.superhuman.com/u/Loi_Quang_Ho)\
**Post date:** [April 25, 2019, 1:57am UTC](https://connect.superhuman.com/t/improved-if-functionality/1599/7 "2019-04-25T01:57:49Z")

</div>

Hi @Al_Chen_Coda

I can name a formula on the writing canvas.  
Sorry if I missed something, I can not do it in the table. Please have a check.

 ![image](https://global.discourse-cdn.com/coda1/original/2X/b/b55ee6f6b928fb4377e4d9b6300ba1bbe2de6de0.png)

---

<div class="post-metadata">

**Author:** ![Al\_Chen\_Coda](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/al_chen_coda/32/5588_2.png) [@Al\_Chen\_Coda](https://connect.superhuman.com/u/Al_Chen_Coda)\
**Post date:** [April 25, 2019, 2:08am UTC](https://connect.superhuman.com/t/improved-if-functionality/1599/8 "2019-04-25T02:08:17Z")

</div>

Correct you can’t name formulas in tables.

---

<div class="post-metadata">

**Author:** ![Josiah\_Krutz](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/josiah_krutz/32/15980_2.png) [@Josiah\_Krutz](https://connect.superhuman.com/u/Josiah_Krutz)\
**Post date:** [April 26, 2019, 1:15am UTC](https://connect.superhuman.com/t/improved-if-functionality/1599/9 "2019-04-26T01:15:53Z")

</div>

@Loi_Quang_Ho You can achieve similar results by making a new column with the long formula, and then using that column in your second formula!

![image](https://global.discourse-cdn.com/coda1/original/2X/c/cc52373d3eff2b06ce3741d501f4fd3d8119bfb2.png)

---

<div class="post-metadata">

**Author:** ![cnr](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/cnr/32/24174_2.png) [@cnr](https://connect.superhuman.com/u/cnr)\
**Post date:** [August 22, 2019, 5:04pm UTC](https://connect.superhuman.com/t/improved-if-functionality/1599/10 "2019-08-22T17:04:27Z")

</div>

Update on this topic. I don’t know if this already existed in Coda when I wrote this, but a new way to get the functionality I asked for is with the `IfBlank()` function.

See the `Flag non-primes` column for the demonstration

Here’s a sample doc:

https://coda.io/embed/UmHzDwW1Xu/_suVd5?viewMode=embedplay

Thank you, Coda!
