# Case expression wiith try for default

**URL:** <https://forum.inductiveautomation.com/t/case-expression-wiith-try-for-default/12418>\
**Category:** Ignition\
**Created:** [November 30, 2016, 4:55pm UTC](https://forum.inductiveautomation.com/t/case-expression-wiith-try-for-default/12418 "2016-11-30T16:55:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mr.K001](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@Mr.K001](https://forum.inductiveautomation.com/u/Mr.K001)\
**Post date:** [November 30, 2016, 4:55pm UTC](https://forum.inductiveautomation.com/t/case-expression-wiith-try-for-default/12418/1 "2016-11-30T16:55:39Z")

</div>

Hi guys, I’m sure the subject line kinda explains it. I basically like to use something like the following:

```auto
case({Hour},
11,{Hourly_PP},
19,{Hourly_PP},
3,{Hourly_PP},
try({Root Container.HourlyCount}[4,'Hourly'],0)
)
```

so basically if we are in those hours show the live tag value of the Hourly\_PP but if we are not there, grab that specific column of the dataset which is an integer and if it doesn’t exist just use zero. I use try because there is no data for hours ahead so I like to show zero for those not NULL.  
I keep getting argument 7 is not a valid type… I thought ‘try’ returns an object and case returns an object as well so why this setup doesn’t seem to work? Thanks in advance! ![:thumb_right:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/2026e28c0c425034352c1b75807edf956adc75f4.gif ":thumb\_right:")

---

<div class="post-metadata">

**Author:** ![Duffanator](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/duffanator/32/3560_2.png) [@Duffanator](https://forum.inductiveautomation.com/u/Duffanator)\
**Post date:** [November 30, 2016, 6:41pm UTC](https://forum.inductiveautomation.com/t/case-expression-wiith-try-for-default/12418/2 "2016-11-30T18:41:51Z")

</div>

Can you wrap the try in a toInt() function?

`case({Hour},
11,{Hourly_PP},
19,{Hourly_PP},
3,{Hourly_PP},
toInt(try({Root Container.HourlyCount}[4,'Hourly'],0))
)`

I’ve found that if the expression interpreter doesn’t know what will be returned it throws an error. Forcing it into a datatype sometimes makes it behave.

---

<div class="post-metadata">

**Author:** ![Mr.K001](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@Mr.K001](https://forum.inductiveautomation.com/u/Mr.K001)\
**Post date:** [November 30, 2016, 6:50pm UTC](https://forum.inductiveautomation.com/t/case-expression-wiith-try-for-default/12418/3 "2016-11-30T18:50:10Z")

</div>

Perfect, Thank you!!!
