# SimulationAids (View expression): Filtering Dataset based off Column Value using String Wild Cards

**URL:** <https://forum.inductiveautomation.com/t/simulationaids-view-expression-filtering-dataset-based-off-column-value-using-string-wild-cards/89175>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [April 21, 2024, 6:48pm UTC](https://forum.inductiveautomation.com/t/simulationaids-view-expression-filtering-dataset-based-off-column-value-using-string-wild-cards/89175 "2024-04-21T18:48:59Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexandro\_Arguello](https://avatars.discourse-cdn.com/v4/letter/a/f05b48/32.png) [@Alexandro\_Arguello](https://forum.inductiveautomation.com/u/Alexandro_Arguello)\
**Post date:** [April 21, 2024, 6:48pm UTC](https://forum.inductiveautomation.com/t/simulationaids-view-expression-filtering-dataset-based-off-column-value-using-string-wild-cards/89175/1 "2024-04-21T18:48:59Z")

</div>

Hi,  
I am trying to use the view expression (direct binding to component) from SimulationAids to filter a dataset based off a String value that is a wildcard, I am having some issues since I am not sure of the pseudo-SQL syntax.

Just for example (where the column name is Station\_Name):  
view("SELECT \* WHERE Station\_Name== '%North%'", {[default]dataset})

This doesn't work, but basically unsure of the syntax to search if the column has that substring ('North') and return the rows in the dataset that have it. the % operators don't work.

Any help is appreciated, I want to see if this would be simple using the module, otherwise I'll just use python and SQL and not the SimulationAids module.

---

<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:** [April 21, 2024, 6:52pm UTC](https://forum.inductiveautomation.com/t/simulationaids-view-expression-filtering-dataset-based-off-column-value-using-string-wild-cards/89175/2 "2024-04-21T18:52:39Z")

</div>

I don't know, but `==` isn't valid SQL and you can't use the single `=` with wildcards. Try,

```sql
SELECT * WHERE Station_Name LIKE '%North%'

```

> **[SQL LIKE Operator](https://www.w3schools.com/sql/sql_like.asp)**
>
> W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.

---

<div class="post-metadata">

**Author:** ![Alexandro\_Arguello](https://avatars.discourse-cdn.com/v4/letter/a/f05b48/32.png) [@Alexandro\_Arguello](https://forum.inductiveautomation.com/u/Alexandro_Arguello)\
**Post date:** [April 21, 2024, 6:54pm UTC](https://forum.inductiveautomation.com/t/simulationaids-view-expression-filtering-dataset-based-off-column-value-using-string-wild-cards/89175/3 "2024-04-21T18:54:16Z")

</div>

The problem is that the view() expression doesn't use SQL, it's pseudo-SQL. The like operator doesn't work

---

<div class="post-metadata">

**Author:** ![Alexandro\_Arguello](https://avatars.discourse-cdn.com/v4/letter/a/f05b48/32.png) [@Alexandro\_Arguello](https://forum.inductiveautomation.com/u/Alexandro_Arguello)\
**Post date:** [April 21, 2024, 6:57pm UTC](https://forum.inductiveautomation.com/t/simulationaids-view-expression-filtering-dataset-based-off-column-value-using-string-wild-cards/89175/4 "2024-04-21T18:57:34Z")

</div>

The code works if the string matches.

For example, this code works for rows where the column name is 'North'.

view("SELECT \* WHERE Station\_Name== 'North'", {[default]dataset})

But I want it to work and return the rows if the string in the column contains 'North' in the string.

Having issues with the syntax for the wildcard since '%' doesn't work

---

<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:** [April 21, 2024, 7:01pm UTC](https://forum.inductiveautomation.com/t/simulationaids-view-expression-filtering-dataset-based-off-column-value-using-string-wild-cards/89175/5 "2024-04-21T19:01:27Z")

</div>

OK. Looking through the [manual](https://www.automation-pros.com/toolkit/doc/scripting.html#pseudo-sql) it says,

```python
Select
  pyExpression,
  pyExpression As ColumnName,
  pyExpression As "Column Name" ...
Where pyConditionalExpression ...

```

The "pyCondidionalExpression" suggests to me that I'm wrong and that your `==` is correct but your `%` wildcard is the problem as that is SQL syntax.

---

<div class="post-metadata">

**Author:** ![Alexandro\_Arguello](https://avatars.discourse-cdn.com/v4/letter/a/f05b48/32.png) [@Alexandro\_Arguello](https://forum.inductiveautomation.com/u/Alexandro_Arguello)\
**Post date:** [April 21, 2024, 7:02pm UTC](https://forum.inductiveautomation.com/t/simulationaids-view-expression-filtering-dataset-based-off-column-value-using-string-wild-cards/89175/6 "2024-04-21T19:02:39Z")

</div>

Yes, the '%' is the issue. I am not sure how to implement this in the view() expression.

---

<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:** [April 21, 2024, 7:02pm UTC](https://forum.inductiveautomation.com/t/simulationaids-view-expression-filtering-dataset-based-off-column-value-using-string-wild-cards/89175/7 "2024-04-21T19:02:53Z")

</div>

This (from the manual) might be useful:

> When in doubt how `view()` is handling your code and data, set its logger to DEBUG, or wrap in the `debugMe()` expression function. This will show you the python whenever it re-compiles, along with execution times. Looking at the generated python will also show other variables you may use in your expressions.

---

<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:** [April 21, 2024, 7:04pm UTC](https://forum.inductiveautomation.com/t/simulationaids-view-expression-filtering-dataset-based-off-column-value-using-string-wild-cards/89175/8 "2024-04-21T19:04:46Z")

</div>

Here comes Phil!

---

<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:** [April 21, 2024, 7:05pm UTC](https://forum.inductiveautomation.com/t/simulationaids-view-expression-filtering-dataset-based-off-column-value-using-string-wild-cards/89175/9 "2024-04-21T19:05:57Z")

</div>

You would use jython's `in` operator to test for a string within another string. Like so:

```python
view(
	"SELECT * WHERE 'North' in Station_Name",
	{[default]dataset}
)

```

However, consider using the `where()` expression function instead, like so:

```python
where(
	{[default]dataset},
	it()['Station_Name'] LIKE '%North%'
)

```

`view()` launches jython, which has much more overhead than the Integration Toolkit's other iteration functions.

{ Ignition's expression language **does** have the `LIKE` operator. }

---

<div class="post-metadata">

**Author:** ![Alexandro\_Arguello](https://avatars.discourse-cdn.com/v4/letter/a/f05b48/32.png) [@Alexandro\_Arguello](https://forum.inductiveautomation.com/u/Alexandro_Arguello)\
**Post date:** [April 21, 2024, 7:07pm UTC](https://forum.inductiveautomation.com/t/simulationaids-view-expression-filtering-dataset-based-off-column-value-using-string-wild-cards/89175/10 "2024-04-21T19:07:45Z")

</div>

Ok, that works. Thanks a lot!
