# Dataset with transform on one column

**URL:** <https://forum.inductiveautomation.com/t/dataset-with-transform-on-one-column/79533>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [September 22, 2023, 9:01pm UTC](https://forum.inductiveautomation.com/t/dataset-with-transform-on-one-column/79533 "2023-09-22T21:01:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [September 22, 2023, 9:01pm UTC](https://forum.inductiveautomation.com/t/dataset-with-transform-on-one-column/79533/1 "2023-09-22T21:01:24Z")

</div>

Is it possible to apply a transform on one column of a dataset (from a named query)?

For example, four integers are returned for this one column, 0-3. I would like to display to the user a string text depending on the number.  
I've applied an expression transform to the whole dataset, but then I don't get everything else.  
Would I need to use `toPyDataset`?

---

<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 23, 2023, 12:28am UTC](https://forum.inductiveautomation.com/t/dataset-with-transform-on-one-column/79533/2 "2023-09-23T00:28:12Z")

</div>

I don't understand what you're asking.

What is the shape of the data. What is the expression that you're applying to it. And what are you trying to ultimately output?

---

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [September 23, 2023, 12:41am UTC](https://forum.inductiveautomation.com/t/dataset-with-transform-on-one-column/79533/3 "2023-09-23T00:41:44Z")

</div>

Column A from the DB table could have values from 0 to 3. I would like to display, in the table column 'One', 'Two', 'Three', for instance, instead of the numerical values.

---

<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 23, 2023, 12:53am UTC](https://forum.inductiveautomation.com/t/dataset-with-transform-on-one-column/79533/4 "2023-09-23T00:53:05Z")

</div>

You can apply a script transform, something like this:

```auto
data = system.dataset.toPyDataset(value)
columnAMap = {0:'Zero',1:'One',2:'Two',3:'Three'}
convertedData = [[row[col] if col != 'ColumnA' else columnAMap[row[col]] for col in data.columnNames] for row in data]

return system.dataset.toDataSet(data.columnNames,convertedData)

```

Probably a more efficient way to do that, but I don't have the brain power tonight. 🤣

---

<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 23, 2023, 1:51pm UTC](https://forum.inductiveautomation.com/t/dataset-with-transform-on-one-column/79533/5 "2023-09-23T13:51:42Z")

</div>

Do it in the query directly.  
Either have another table with the mapping to text values and join on that table, or use a case:

```sql
select
  case num_column
    when 1 then ‘one’
    when 2 then ‘two’
    …
  end
from some_table

```
