# How to check if a value is inside an array in the expression tag editor?

**URL:** <https://forum.inductiveautomation.com/t/how-to-check-if-a-value-is-inside-an-array-in-the-expression-tag-editor/98193>\
**Category:** Ignition\
**Tags:** ignition81, scripting\
**Created:** [November 5, 2024, 9:59am UTC](https://forum.inductiveautomation.com/t/how-to-check-if-a-value-is-inside-an-array-in-the-expression-tag-editor/98193 "2024-11-05T09:59:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zied\_Brahmi](https://avatars.discourse-cdn.com/v4/letter/z/5daacb/32.png) [@Zied\_Brahmi](https://forum.inductiveautomation.com/u/Zied_Brahmi)\
**Post date:** [November 5, 2024, 9:59am UTC](https://forum.inductiveautomation.com/t/how-to-check-if-a-value-is-inside-an-array-in-the-expression-tag-editor/98193/1 "2024-11-05T09:59:58Z")

</div>

Hello Forum,

in my expression tag, I need my tag to have this value:

Let's say I have a value x and I want to check it if it's inside an array or no.  
so basically the expression will be:

```python
x in myArray

```

how can I do that in my expression tag?

Thank you

---

<div class="post-metadata">

**Author:** ![danielps1818](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@danielps1818](https://forum.inductiveautomation.com/u/danielps1818)\
**Post date:** [November 5, 2024, 10:46am UTC](https://forum.inductiveautomation.com/t/how-to-check-if-a-value-is-inside-an-array-in-the-expression-tag-editor/98193/2 "2024-11-05T10:46:41Z")

</div>

Did you try `lookup()`?

> **[lookup | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/appendix/expression-functions/logic/lookup)**
>
> This looks for lookupValue in the lookupColumn of dataset.

Hadn't tested it and not sure about your tag type.

---

<div class="post-metadata">

**Author:** ![Samuel\_Sueur](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@Samuel\_Sueur](https://forum.inductiveautomation.com/u/Samuel_Sueur)\
**Post date:** [November 5, 2024, 11:59am UTC](https://forum.inductiveautomation.com/t/how-to-check-if-a-value-is-inside-an-array-in-the-expression-tag-editor/98193/3 "2024-11-05T11:59:29Z")

</div>

If it's a string array (it maybe works with other array types as well, haven't tested this) and your gateway version is 8.1.8+, you could use the expression function `indexOf`.

> **[indexOf | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/appendix/expression-functions/logic/indexOf)**
>
> Searches for the first occurrence of the substring inside of string. Returns the index of where substring was found, or -1 if it wasn't found.

---

<div class="post-metadata">

**Author:** ![Zied\_Brahmi](https://avatars.discourse-cdn.com/v4/letter/z/5daacb/32.png) [@Zied\_Brahmi](https://forum.inductiveautomation.com/u/Zied_Brahmi)\
**Post date:** [November 5, 2024, 1:06pm UTC](https://forum.inductiveautomation.com/t/how-to-check-if-a-value-is-inside-an-array-in-the-expression-tag-editor/98193/4 "2024-11-05T13:06:26Z")

</div>

thank you for your response, I already tried this one and it didn't work, my array in a hardcoded array of integers

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [November 5, 2024, 1:13pm UTC](https://forum.inductiveautomation.com/t/how-to-check-if-a-value-is-inside-an-array-in-the-expression-tag-editor/98193/5 "2024-11-05T13:13:00Z")

</div>

if it's hardcoded, consider using a dataset tag with a lookup() expression.

---

<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:** [November 5, 2024, 4:40pm UTC](https://forum.inductiveautomation.com/t/how-to-check-if-a-value-is-inside-an-array-in-the-expression-tag-editor/98193/6 "2024-11-05T16:40:57Z")

</div>

`indexOf` is absolutely the solution here and works regardless of array/list type _as long as the value you're looking up also matches that type_.
