# Perspective instances (flexrepeater) help

**URL:** <https://forum.inductiveautomation.com/t/perspective-instances-flexrepeater-help/68397>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [January 9, 2023, 9:41pm UTC](https://forum.inductiveautomation.com/t/perspective-instances-flexrepeater-help/68397 "2023-01-09T21:41:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kelltek](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@Kelltek](https://forum.inductiveautomation.com/u/Kelltek)\
**Post date:** [January 9, 2023, 9:42pm UTC](https://forum.inductiveautomation.com/t/perspective-instances-flexrepeater-help/68397/1 "2023-01-09T21:42:00Z")

</div>

I have a Dataset that I query into the instances binding. I loop through the data and make some adjustments in my new dataset. a single column data set errors out. a list errors out the only format that works is json. I can RETURN a json but when I adjust it in the binding then the object that I start with is no longer a dataset. Is there a quick way to change this?

---

<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:** [January 9, 2023, 10:00pm UTC](https://forum.inductiveautomation.com/t/perspective-instances-flexrepeater-help/68397/2 "2023-01-09T22:00:42Z")

</div>

Add a custom property to the repeater. Move the original dataset binding there (and make it private, as you won't need it transmitted to the browser). Bind the original instances property to this custom property, and add a transform to yield the desired json. Perform the adjustments in the same loop. Your instances will get the adjustments, and both dataset and adjusted json will be available to other event scripts.

---

<div class="post-metadata">

**Author:** ![Kelltek](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@Kelltek](https://forum.inductiveautomation.com/u/Kelltek)\
**Post date:** [January 9, 2023, 10:07pm UTC](https://forum.inductiveautomation.com/t/perspective-instances-flexrepeater-help/68397/3 "2023-01-09T22:07:11Z")

</div>

> [@pturmel](#):
>
> n

This leaves me in the same position. My source query can be "returned" as a dataset or JSON. This does not just alter the return but the structure of the provided data before the transform.

If I use expression or prop binding on on my custom dataset I need to parse through it manually again and convert it to a json object?

---

<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:** [January 9, 2023, 10:30pm UTC](https://forum.inductiveautomation.com/t/perspective-instances-flexrepeater-help/68397/4 "2023-01-09T22:30:12Z")

</div>

Yes, you will need to convert to a list of dictionaries to mimic the JSON return format. The transform would look something like this:

```auto
def transform(self, value, quality, timestamp):
	cNames = list(value.columnNames)
	output = []
	for r in range(value.rowCount):
		newRow = dict([(c, value.getValueAt(r, c)) for c in cNames])
		output.append(newRow)
	return output

```

That is essentially what JSON format does under the hood. You can insert your code to make adjustments between creating `newRow` and appending it to `output`.

---

<div class="post-metadata">

**Author:** ![Kelltek](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@Kelltek](https://forum.inductiveautomation.com/u/Kelltek)\
**Post date:** [January 13, 2023, 7:01pm UTC](https://forum.inductiveautomation.com/t/perspective-instances-flexrepeater-help/68397/5 "2023-01-13T19:01:55Z")

</div>

This solution does work however I am stumbling with the dictionary format but the single line is confusing me. Can I create multiple dictionary entries or does the list limit how many "rows" each dictionary can have?  
Additionally, I am doing a tag read in the for loop and trying to use output.insert(index, newRow) to place my instances in a certain order dynamically. While my code seems to be working the list order itself does not change. Am I missing something in how this object is working?

---

<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:** [January 13, 2023, 7:12pm UTC](https://forum.inductiveautomation.com/t/perspective-instances-flexrepeater-help/68397/6 "2023-01-13T19:12:43Z")

</div>

Show your current code, a sample of your data, and show how you **want** it to come out. Then we can make concrete suggestions.

(Don't show screenshots of code. Paste code, select what you paste, then click the "Preformatted Text" button to make a code block.)

---

<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:** [January 13, 2023, 7:22pm UTC](https://forum.inductiveautomation.com/t/perspective-instances-flexrepeater-help/68397/7 "2023-01-13T19:22:36Z")

</div>

> [@Kelltek](#):
>
> I am stumbling with the dictionary format

Python's dictionary constructor (the `dict()` function) accepts an initializer in the form of nested iterables, where the inner iterables (I used tuples) are length two: a key and a value. So the line beginning with `newRow =` is constructing a dictionary and initializing it with a list of tuples: column name and value for that row & column. You might want to look up "list comprehensions" in the python docs.

Between that row and the `.append()` operation, you can make more assignments to the dictionary to make arbitrary computed columns, of the form:

```auto
    newRow['someColumnName'] = someExpression

```

You can also re-assign over the original values if needed. Or use python's `del` statement to discard information.
