# Flipping Boolean tag

**URL:** <https://forum.inductiveautomation.com/t/flipping-boolean-tag/93644>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [July 24, 2024, 4:13am UTC](https://forum.inductiveautomation.com/t/flipping-boolean-tag/93644 "2024-07-24T04:13:35Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![thomas\_wallace](https://avatars.discourse-cdn.com/v4/letter/t/57b2e6/32.png) [@thomas\_wallace](https://forum.inductiveautomation.com/u/thomas_wallace)\
**Post date:** [July 24, 2024, 4:13am UTC](https://forum.inductiveautomation.com/t/flipping-boolean-tag/93644/1 "2024-07-24T04:13:35Z")

</div>

Is it possibly to switch a Boolean tag to always read the opposite of what it really is? I need it to say true when its false and vise versa.

---

<div class="post-metadata">

**Author:** ![benp](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/benp/32/34073_2.png) [@benp](https://forum.inductiveautomation.com/u/benp)\
**Post date:** [July 24, 2024, 4:18am UTC](https://forum.inductiveautomation.com/t/flipping-boolean-tag/93644/2 "2024-07-24T04:18:17Z")

</div>

Hi,  
Is it an OPC tag or not?

You can use derived tags that references another tag and can transform its read or write value with an expression.

> **[Types of Tags | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/platform/tags/types-of-tags)**
>
> There are many different types of Tags in Ignition: standard Tags, System Tags, and Vision Client Tags. All these Tag types are available in the Tag Browser.

Otherwise anywhere you read or bind this tag value you can just invert its value in scripts or expressions. It all depends on what you're trying to do here.

---

<div class="post-metadata">

**Author:** ![thomas\_wallace](https://avatars.discourse-cdn.com/v4/letter/t/57b2e6/32.png) [@thomas\_wallace](https://forum.inductiveautomation.com/u/thomas_wallace)\
**Post date:** [July 24, 2024, 1:00pm UTC](https://forum.inductiveautomation.com/t/flipping-boolean-tag/93644/3 "2024-07-24T13:00:33Z")

</div>

@benp It’s an OPC tag

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [July 24, 2024, 1:01pm UTC](https://forum.inductiveautomation.com/t/flipping-boolean-tag/93644/4 "2024-07-24T13:01:23Z")

</div>

You need a second tag. If you only need to read it can be an expression tag, otherwise a derived tag.

---

<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:** [July 24, 2024, 2:36pm UTC](https://forum.inductiveautomation.com/t/flipping-boolean-tag/93644/5 "2024-07-24T14:36:53Z")

</div>

> [@thomas\_wallace](#):
>
> ... switch a Boolean tag to always read the opposite of what it really is?

Is this related to your previous question, [Adding values together only if tag is true](https://forum.inductiveautomation.com/t/adding-values-together-only-if-tag-is-true/93640)?

The Expression Language has a built-in negation, `!`. The expression I gave would convert to,

```python
!{[default]Bool0} * {[default]Other0} +
!{[default]Bool1} * {[default]Other1} +
!{[default]Bool2} * {[default]Other2} +
... +
!{[default]Bool159} * {[default]Other159}

```

Python / Jython has the `not` operator.

---

<div class="post-metadata">

**Author:** ![thomas\_wallace](https://avatars.discourse-cdn.com/v4/letter/t/57b2e6/32.png) [@thomas\_wallace](https://forum.inductiveautomation.com/u/thomas_wallace)\
**Post date:** [July 24, 2024, 4:37pm UTC](https://forum.inductiveautomation.com/t/flipping-boolean-tag/93644/6 "2024-07-24T16:37:21Z")

</div>

@Kevin.Herron I will need historian for it if that’s what you’re asking.

---

<div class="post-metadata">

**Author:** ![thomas\_wallace](https://avatars.discourse-cdn.com/v4/letter/t/57b2e6/32.png) [@thomas\_wallace](https://forum.inductiveautomation.com/u/thomas_wallace)\
**Post date:** [July 24, 2024, 4:38pm UTC](https://forum.inductiveautomation.com/t/flipping-boolean-tag/93644/7 "2024-07-24T16:38:43Z")

</div>

@Transistor it is related to it. I used your method for my expression. Didn’t realize one of the tags is reading the opposite of what I need it to. So it’s ignoring the tags when it shouldn’t.

---

<div class="post-metadata">

**Author:** ![thomas\_wallace](https://avatars.discourse-cdn.com/v4/letter/t/57b2e6/32.png) [@thomas\_wallace](https://forum.inductiveautomation.com/u/thomas_wallace)\
**Post date:** [July 24, 2024, 5:43pm UTC](https://forum.inductiveautomation.com/t/flipping-boolean-tag/93644/8 "2024-07-24T17:43:26Z")

</div>

`{[default]779/CabTrimAGVs/AGVProgram/AGV01/B2} * {[default]779/CabTrimAGVs/AGVStatus/AGV01/R5} * {[default]779/CabTrimAGVs/AGVStatus/AGV01/B30} +`

I need the third line to read the opposite.

---

<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:** [July 24, 2024, 5:57pm UTC](https://forum.inductiveautomation.com/t/flipping-boolean-tag/93644/9 "2024-07-24T17:57:26Z")

</div>

You haven't added the NOT operator, `'!'` as shown in post #5.

---

<div class="post-metadata">

**Author:** ![thomas\_wallace](https://avatars.discourse-cdn.com/v4/letter/t/57b2e6/32.png) [@thomas\_wallace](https://forum.inductiveautomation.com/u/thomas_wallace)\
**Post date:** [July 24, 2024, 6:09pm UTC](https://forum.inductiveautomation.com/t/flipping-boolean-tag/93644/10 "2024-07-24T18:09:21Z")

</div>

I was confused by that post. I completely missed the "!" you added at the beginning.

---

<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:** [July 24, 2024, 6:16pm UTC](https://forum.inductiveautomation.com/t/flipping-boolean-tag/93644/11 "2024-07-24T18:16:54Z")

</div>

OK.

Tip: if you are responding to someone on the forum then either, hit the reply button below their post or use the `@username` syntax. Then that user will receive a notification in their inbox (as you have for this post).

More reading:

> **[Expression Language and Syntax | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.1/platform/expression-language-and-syntax#operators)**
>
> Expression Language

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [July 24, 2024, 7:33pm UTC](https://forum.inductiveautomation.com/t/flipping-boolean-tag/93644/12 "2024-07-24T19:33:46Z")

</div>

Depends on the exact use case, but there is a `bitInversion` value scaling option for tags.

---

<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:** [July 24, 2024, 7:39pm UTC](https://forum.inductiveautomation.com/t/flipping-boolean-tag/93644/13 "2024-07-24T19:39:00Z")

</div>

![Bit inversion](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/5/a5b8254d4ec9bca9a0f36153602df5a840923515.png)

Oooh! I didn't know that!

@thomas_wallace that might work for you if you don't need it in it's non-inverted format somewhere else.

---

<div class="post-metadata">

**Author:** ![thomas\_wallace](https://avatars.discourse-cdn.com/v4/letter/t/57b2e6/32.png) [@thomas\_wallace](https://forum.inductiveautomation.com/u/thomas_wallace)\
**Post date:** [July 24, 2024, 8:12pm UTC](https://forum.inductiveautomation.com/t/flipping-boolean-tag/93644/14 "2024-07-24T20:12:47Z")

</div>

@amarks @Transistor That is very useful to know. I do need it in its normal state for other things. So I used transistors way. I will remember this though. Thank you.
