# Scalar query returns unicode when it should be a float

**URL:** <https://forum.inductiveautomation.com/t/scalar-query-returns-unicode-when-it-should-be-a-float/115513>\
**Category:** Ignition\
**Created:** [May 13, 2026, 3:58pm UTC](https://forum.inductiveautomation.com/t/scalar-query-returns-unicode-when-it-should-be-a-float/115513 "2026-05-13T15:58:13Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bwhite](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bwhite/32/7112_2.png) [@bwhite](https://forum.inductiveautomation.com/u/bwhite)\
**Post date:** [May 13, 2026, 3:58pm UTC](https://forum.inductiveautomation.com/t/scalar-query-returns-unicode-when-it-should-be-a-float/115513/1 "2026-05-13T15:58:13Z")

</div>

I have a scalar named query that does a calculation on two values in a table and returns the answer. When the operator does not enter the values for that day, the query should return the fallback value of 0. However, it returns a unicode 0 instead. I have tried casting the value as a float in the query, but it still returns unicode. How can I either fix it in the query to return a value of 0.0 or fix it in the script where I run the query? In the script, I need the 0 to be a value because I am doing more calculations on it.

---

<div class="post-metadata">

**Author:** ![aspatchek2013](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/aspatchek2013/32/85339_2.png) [@aspatchek2013](https://forum.inductiveautomation.com/u/aspatchek2013)\
**Post date:** [May 13, 2026, 4:20pm UTC](https://forum.inductiveautomation.com/t/scalar-query-returns-unicode-when-it-should-be-a-float/115513/2 "2026-05-13T16:20:04Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/c/6c7fe606797c1972d4dfb7ddf41f626989420879.png)

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [May 13, 2026, 4:30pm UTC](https://forum.inductiveautomation.com/t/scalar-query-returns-unicode-when-it-should-be-a-float/115513/3 "2026-05-13T16:30:16Z")

</div>

If it is MSSQL you can wrap the calculation in your query with a COALESCE

`SELECT COALESCE([Field1]+[FIELD2],0.0) as Result`

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [May 13, 2026, 4:43pm UTC](https://forum.inductiveautomation.com/t/scalar-query-returns-unicode-when-it-should-be-a-float/115513/4 "2026-05-13T16:43:20Z")

</div>

I think scalar NQs with a fallback always casts the result to a string. I've run into this issue before.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 13, 2026, 4:51pm UTC](https://forum.inductiveautomation.com/t/scalar-query-returns-unicode-when-it-should-be-a-float/115513/5 "2026-05-13T16:51:47Z")

</div>

@dkhayes117 is correct per the code. Since their inception the fallback value in named queries has been hardcoded to string. 😬

---

<div class="post-metadata">

**Author:** ![bwhite](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bwhite/32/7112_2.png) [@bwhite](https://forum.inductiveautomation.com/u/bwhite)\
**Post date:** [May 13, 2026, 5:09pm UTC](https://forum.inductiveautomation.com/t/scalar-query-returns-unicode-when-it-should-be-a-float/115513/6 "2026-05-13T17:09:20Z")

</div>

This didn't work. It still came back as unicode.

SELECT COELESCE((([End]-[Start]) \*0.35),0.0) AS Tons  
FROM [table]  
WHERE [id] = :id

---

<div class="post-metadata">

**Author:** ![bwhite](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bwhite/32/7112_2.png) [@bwhite](https://forum.inductiveautomation.com/u/bwhite)\
**Post date:** [May 13, 2026, 5:09pm UTC](https://forum.inductiveautomation.com/t/scalar-query-returns-unicode-when-it-should-be-a-float/115513/7 "2026-05-13T17:09:37Z")

</div>

This worked!
