# Number-to-Color translation

**URL:** <https://forum.inductiveautomation.com/t/number-to-color-translation/1161>\
**Category:** Archived Topics\
**Created:** [May 21, 2009, 3:47pm UTC](https://forum.inductiveautomation.com/t/number-to-color-translation/1161 "2009-05-21T15:47:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlThePal](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/althepal/32/3603_2.png) [@AlThePal](https://forum.inductiveautomation.com/u/AlThePal)\
**Post date:** [May 21, 2009, 3:47pm UTC](https://forum.inductiveautomation.com/t/number-to-color-translation/1161/1 "2009-05-21T15:47:35Z")

</div>

I’m trying to change the colour of an object based on a value, but what I’m trying to achieve doesn’t seem possible with the standard Number-to-Color Translation feature.

I’m trying to achieve the following:

Value=0, colour 1  
Value=+ve number up to 100, colour 2  
Value= greater than 100 up to 200, colour 3

The problem is if I put an entry of 0 in the translation table, it considers any number from 0 to the next entry as one case i.e. it doesn’t consider 0 as a separate case.

Is it possible to do this? I tried putting in an entry of 0.001, but it doesn’t accept floating point numbers, even though the value being compared is a float.

Al

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [May 21, 2009, 3:58pm UTC](https://forum.inductiveautomation.com/t/number-to-color-translation/1161/2 "2009-05-21T15:58:18Z")

</div>

You’re right, the number-to-color binding doesn’t play well with floating point numbers.

You have 2 options:

1. Use the Styles feature - it handles floating point much better.
2. Use an expression, with some nested if() functions and the color() function, you can acheive this logic simply.

---

<div class="post-metadata">

**Author:** ![AlThePal](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/althepal/32/3603_2.png) [@AlThePal](https://forum.inductiveautomation.com/u/AlThePal)\
**Post date:** [May 21, 2009, 6:03pm UTC](https://forum.inductiveautomation.com/t/number-to-color-translation/1161/3 "2009-05-21T18:03:14Z")

</div>

Thanks for the tips Carl. Styles do handle floating point numbers 🙂 - but only to 2 decimal places ☹ . This means it may not work correctly, as the limit should really be the smallest possible floating point number.

Nested if() statements worked, although the 10 closing brackets are a bit mind boggling! It’s a shame the number-to-color binding doesn’t work. The only way I could see it working in this situation is if you allow the selection of ‘\>’, ‘=’ or ‘\>=’ for each entry.

Al
