# How do I replace the map with its equivalent expression?

**URL:** <https://forum.inductiveautomation.com/t/how-do-i-replace-the-map-with-its-equivalent-expression/110429>\
**Category:** Ignition\
**Created:** [September 6, 2025, 6:20pm UTC](https://forum.inductiveautomation.com/t/how-do-i-replace-the-map-with-its-equivalent-expression/110429 "2025-09-06T18:20:07Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![gbalarez](https://avatars.discourse-cdn.com/v4/letter/g/73ab20/32.png) [@gbalarez](https://forum.inductiveautomation.com/u/gbalarez)\
**Post date:** [September 6, 2025, 6:20pm UTC](https://forum.inductiveautomation.com/t/how-do-i-replace-the-map-with-its-equivalent-expression/110429/1 "2025-09-06T18:20:07Z")

</div>

![{960C44D9-F751-4E0E-8198-5D6736E64D47}](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/6/76fcf2068af903611e25a54394e3cb8e342216f5.png)

How do I replace the map with its equivalent expression? I tried case, switch, if, and I got an error.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 6, 2025, 6:53pm UTC](https://forum.inductiveautomation.com/t/how-do-i-replace-the-map-with-its-equivalent-expression/110429/2 "2025-09-06T18:53:54Z")

</div>

Please explain what's wrong with your map first!

Note that your map transform inputs don't cater for values between 114 - 115, 129 - 130, etc. You should be using,

```python
[80, 115)
[115, 130)
[130, 140)
[140, 180)
[180, 200]

```

Note the `[` (inclusive) and `)` (exclusive).

> **Numeric Range** : A range of values that the incoming value will fall between. Use brackets [x,y] to indicate values that are to be inclusive, or parenthesis for values that are exclusive (x,y), and you can mix them as needed. You can also omit start or end values to indicate no end to the range.  
> [Map Transform | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.1/ignition-modules/perspective/working-with-perspective-components/bindings-in-perspective/transforms/map-transform#input-type)

---

<div class="post-metadata">

**Author:** ![Chris\_Bingham](https://avatars.discourse-cdn.com/v4/letter/c/e5b9ba/32.png) [@Chris\_Bingham](https://forum.inductiveautomation.com/u/Chris_Bingham)\
**Post date:** [September 8, 2025, 4:33am UTC](https://forum.inductiveautomation.com/t/how-do-i-replace-the-map-with-its-equivalent-expression/110429/3 "2025-09-08T04:33:59Z")

</div>

> [@gbalarez](#):
>
> replace the map with its equivalent expression?

Using nested `if` statements within an expression transform:

```python
if(({value} > 80) && ({value} < 114), 0.5316,
if(({value} > 115) && ({value} < 129), 0.545,
if(..., ...,
null
)))

```

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [September 8, 2025, 7:39am UTC](https://forum.inductiveautomation.com/t/how-do-i-replace-the-map-with-its-equivalent-expression/110429/4 "2025-09-08T07:39:14Z")

</div>

You can use `case` instead:

```python
case (true),
    80 <= x && x <= 114, 0.5316,
    115 <= x && x <= 129, 0.545,
    ...
)

```

Makes things a bit easier to maintain than nested ifs.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [September 8, 2025, 10:51am UTC](https://forum.inductiveautomation.com/t/how-do-i-replace-the-map-with-its-equivalent-expression/110429/5 "2025-09-08T10:51:19Z")

</div>

> [@Chris\_Bingham](#):
>
> within an expression transform:

Don’t use a transform when you can just use an expression. No need for the extra processing step.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 8, 2025, 11:44am UTC](https://forum.inductiveautomation.com/t/how-do-i-replace-the-map-with-its-equivalent-expression/110429/6 "2025-09-08T11:44:48Z")

</div>

> [@pascal.fragnoud](#):
>
> ```python
> case (true),
> 80 <= x && x <= 114, 0.5316,
> 
> ```

Pascal, are you getting mixed up with C syntax? What's `x` in there?  
(Your `( )`s don't pair up properly either!)

I had wondered about case testing ranges before but thought it couldn't be done.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 8, 2025, 12:03pm UTC](https://forum.inductiveautomation.com/t/how-do-i-replace-the-map-with-its-equivalent-expression/110429/7 "2025-09-08T12:03:21Z")

</div>

> [@Chris\_Bingham](#):
>
> ```python
> if(({value} > 80) && ({value} < 114), 0.5316,
> if(({value} > 115) && ({value} < 129), 0.545,
> if(..., ...,
> null
> )))
> 
> ```

Assuming the OP has left out catering for values between 114 and 115 in error, this could become,

```python
if({value} > 200, null,
if({value} > 180, 0.5712,
if({value} > 140, 0.5643,
if({value} > 130, 0.5543,
if({value} > 115, 0.545,
if({value} > 80, 0.5316,
null
))))))

```

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [September 8, 2025, 12:04pm UTC](https://forum.inductiveautomation.com/t/how-do-i-replace-the-map-with-its-equivalent-expression/110429/8 "2025-09-08T12:04:18Z")

</div>

Yes I was a bit careless with the example.  
`x` is just a placeholder. The parenthesis are indeed misplaced. Kind of forgot expression syntax.

```python
case (true,
    80 <= {value} && {value} <= 114, 0.5316,
    115 <= {value} && {value} <= 129, 0.545,
    [condition], [value],
    [some default if no case match]
)

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 8, 2025, 12:10pm UTC](https://forum.inductiveautomation.com/t/how-do-i-replace-the-map-with-its-equivalent-expression/110429/9 "2025-09-08T12:10:08Z")

</div>

If one of the motivations of the OP is to do this outside Perspective, where there aren't any transforms, my Integration Toolkit's functions can help. Like so:

```python
transform(
    {path/to/x},
    case (true,
        80 <= value() && value() <= 114, 0.5316,
        115 <= value() && value() <= 129, 0.545,
        [some condition on value()], [some result],
        [some default result if no case match]
    )
)

```
