# Converting Span to Percentage / Another Span

**URL:** <https://discourse.nodered.org/t/converting-span-to-percentage-another-span/68789>\
**Category:** General\
**Created:** [10 October 2022 09:15 UTC](https://discourse.nodered.org/t/converting-span-to-percentage-another-span/68789 "2022-10-10T09:15:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kolbep](https://avatars.discourse-cdn.com/v4/letter/k/49beb7/32.png) [@kolbep](https://discourse.nodered.org/u/kolbep)\
**Post date:** [10 October 2022 09:15 UTC](https://discourse.nodered.org/t/converting-span-to-percentage-another-span/68789/1 "2022-10-10T09:15:21Z")

</div>

Hi All,

I dont know how to phrase this, and I am not feeling well today, so my brain is working at half speed.

Anyway, I have a SR04 Ultrasonic Distance Sensor feeding into Nodered (via Tasmota) for a Water Tank.

When the tank is full, the distance to sensor is 19cm, when the tank is empty, the distance to sensor is 150cm.

I need a way to convert the span of 19cm-\>150cm into 100% to 0% or similar, so that it is more humanly readable.

Is there an easy way to do this. I would probably figure it out if I was firing on all 4 cylinders today.

Thanks

---

<div class="post-metadata">

**Author:** ![kolbep](https://avatars.discourse-cdn.com/v4/letter/k/49beb7/32.png) [@kolbep](https://discourse.nodered.org/u/kolbep)\
**Post date:** [10 October 2022 09:27 UTC](https://discourse.nodered.org/t/converting-span-to-percentage-another-span/68789/2 "2022-10-10T09:27:09Z")

</div>

Nevermind.  
Found the 'Range' Node. That looks like it is what I was looking for,

Peter

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [10 October 2022 10:56 UTC](https://discourse.nodered.org/t/converting-span-to-percentage-another-span/68789/3 "2022-10-10T10:56:13Z")

</div>

Indeed it is... should be fine for simple cases... If your tank is some other shape (tapered for example) then Bart's [tank volume node](https://flows.nodered.org/node/node-red-contrib-tank-volume) may be better

---

<div class="post-metadata">

**Author:** ![kolbep](https://avatars.discourse-cdn.com/v4/letter/k/49beb7/32.png) [@kolbep](https://discourse.nodered.org/u/kolbep)\
**Post date:** [10 October 2022 12:26 UTC](https://discourse.nodered.org/t/converting-span-to-percentage-another-span/68789/4 "2022-10-10T12:26:40Z")

</div>

Thanks.  
The tanks are cylindrical, so it is easy enough to do that span using that Range Node.

Peter

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [24 October 2022 12:26 UTC](https://discourse.nodered.org/t/converting-span-to-percentage-another-span/68789/5 "2022-10-24T12:26:49Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
