# Creating a transform to modify the displaying of a pydataset

**URL:** <https://forum.inductiveautomation.com/t/creating-a-transform-to-modify-the-displaying-of-a-pydataset/76078>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [July 7, 2023, 7:26pm UTC](https://forum.inductiveautomation.com/t/creating-a-transform-to-modify-the-displaying-of-a-pydataset/76078 "2023-07-07T19:26:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cameron\_Nickle](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@Cameron\_Nickle](https://forum.inductiveautomation.com/u/Cameron_Nickle)\
**Post date:** [July 7, 2023, 7:26pm UTC](https://forum.inductiveautomation.com/t/creating-a-transform-to-modify-the-displaying-of-a-pydataset/76078/1 "2023-07-07T19:26:56Z")

</div>

Hi all,

I've been working on trying to find a way to display only the data I am interested in from a pydataset using a transform. I've tried a few different types of transforms to make this happen and I've been unsuccessful and I'm hoping someone can give me a hand.

I currently have a named query binding on a table in perspective that is returning a dataset. What I want to do is go into this dataset and make it so only 2 of the 3 roles I have set for a specific user appear on the table.

It would look something like this:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/c/9c3ba1ba8465c6990572efba1e63bd46080efff6.png)

where the role "Administrator" does not appear on the table for example.

Thank you,

Cam

---

<div class="post-metadata">

**Author:** ![josborn](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@josborn](https://forum.inductiveautomation.com/u/josborn)\
**Post date:** [July 7, 2023, 8:00pm UTC](https://forum.inductiveautomation.com/t/creating-a-transform-to-modify-the-displaying-of-a-pydataset/76078/2 "2023-07-07T20:00:57Z")

</div>

If the roles field is a string then a script transform like this might work:

```auto
	for row in range(value.getRowCount()):
		newData = system.dataset.setValue(value, row, 'role', value.getValueAt(row, 'role').replace('Adminstrator,', ''))
	return newData

```

I think @pturmel's simulation aids module might be able to do what you want with expressions.

---

<div class="post-metadata">

**Author:** ![Cameron\_Nickle](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@Cameron\_Nickle](https://forum.inductiveautomation.com/u/Cameron_Nickle)\
**Post date:** [July 14, 2023, 5:16pm UTC](https://forum.inductiveautomation.com/t/creating-a-transform-to-modify-the-displaying-of-a-pydataset/76078/3 "2023-07-14T17:16:01Z")

</div>

Hi @josborn,

I was using a modification of the script you sent me but it seems to only work for 1 row and any row after that the role will still appear. Specifically, it only works for the last row in the table of question. How would I go about modifying it again so that it will modify all the rows?

---

<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:** [July 14, 2023, 5:29pm UTC](https://forum.inductiveautomation.com/t/creating-a-transform-to-modify-the-displaying-of-a-pydataset/76078/4 "2023-07-14T17:29:39Z")

</div>

The problem with this script is that it uses `value` as the source dataset but assigns the result to `newData`.  
So on every iteration, it still uses the original dataset, which is why you only get the very last modification.  
To fix it, replace `newData` with `value`.

---

<div class="post-metadata">

**Author:** ![Cameron\_Nickle](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@Cameron\_Nickle](https://forum.inductiveautomation.com/u/Cameron_Nickle)\
**Post date:** [July 14, 2023, 5:33pm UTC](https://forum.inductiveautomation.com/t/creating-a-transform-to-modify-the-displaying-of-a-pydataset/76078/5 "2023-07-14T17:33:00Z")

</div>

That makes a lot of sense and I'm sad I overlooked that, but that's okay.

Thank you @pascal.fragnoud 😃
