# How to create Dataset from tags?

**URL:** <https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243>\
**Category:** Maker\
**Tags:** perspective\
**Created:** [January 13, 2024, 6:03pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243 "2024-01-13T18:03:35Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vidar\_Hetlelid](https://avatars.discourse-cdn.com/v4/letter/v/dfb087/32.png) [@Vidar\_Hetlelid](https://forum.inductiveautomation.com/u/Vidar_Hetlelid)\
**Post date:** [January 13, 2024, 6:03pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/1 "2024-01-13T18:03:35Z")

</div>

Hi there,

How can I create a dataset that I can use in a table? I have many tags, that i want to display in a table.

---

<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, 2024, 6:19pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/2 "2024-01-13T18:19:25Z")

</div>

I presume you want to display **live** tag values?

You should create a dataset or list containing your tag paths. On the table, configure the column with the tagpath to have a column view instead of normal rendering.

In the specified column view, include an input parameter named `value`--this will receive the tag path. Configure custom properties in that column view with indirect bindings to the tag (for the value), and for any tag properties that you want to use to control formatting. (Probably at least the `.formatString` and `.engUnit` properties.)

Place one or more labels in the column view to actually display the live value, formatted as desired.

You probably want the table itself to be set to virtual mode, so that non-visible rows don't run their live values.

---

<div class="post-metadata">

**Author:** ![Vidar\_Hetlelid](https://avatars.discourse-cdn.com/v4/letter/v/dfb087/32.png) [@Vidar\_Hetlelid](https://forum.inductiveautomation.com/u/Vidar_Hetlelid)\
**Post date:** [January 13, 2024, 6:24pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/3 "2024-01-13T18:24:54Z")

</div>

> [@pturmel](#):
>
> You should create a dataset or list containing your tag paths. On the table, configure the column with the tagpath to have a column view instead of normal rendering.

Thanks! Yes i want live values. Where do I create this list or dataset?

---

<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, 2024, 6:26pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/4 "2024-01-13T18:26:38Z")

</div>

To get started, just make it by hand. One complete tagpath string per row.

---

<div class="post-metadata">

**Author:** ![Vidar\_Hetlelid](https://avatars.discourse-cdn.com/v4/letter/v/dfb087/32.png) [@Vidar\_Hetlelid](https://forum.inductiveautomation.com/u/Vidar_Hetlelid)\
**Post date:** [January 13, 2024, 6:29pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/5 "2024-01-13T18:29:29Z")

</div>

Do you mean I should edit the values here, to be a tag path?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/7/e78b63238042f21212b73592fa5beba551a6b7f3.png)

---

<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, 2024, 6:33pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/6 "2024-01-13T18:33:33Z")

</div>

Yes. Just make the key `tagpath`, and the value the string. Just a couple rows to test with. In the `columns` property, configure one column using that tagpath, and configure `render` to view:

[https://docs.inductiveautomation.com/display/DOC81/Table+Column+Configurations#TableColumnConfigurations-EmbeddingaViewinaTableCell](https://docs.inductiveautomation.com/display/DOC81/Table+Column+Configurations#TableColumnConfigurations-EmbeddingaViewinaTableCell)

Then make a row-like view as described that accepts the tagpath as its `value` parameter.

---

<div class="post-metadata">

**Author:** ![Vidar\_Hetlelid](https://avatars.discourse-cdn.com/v4/letter/v/dfb087/32.png) [@Vidar\_Hetlelid](https://forum.inductiveautomation.com/u/Vidar_Hetlelid)\
**Post date:** [January 14, 2024, 2:15pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/7 "2024-01-14T14:15:32Z")

</div>

Thank you! So i get this to work when its created manually.

How can I make this a dynamic dataset? I want to have the amount of rows to be dependent on how many elements there is in a array i.e. Is this possible? 🙂

EDIT:  
Actually ive managed to create a dataset for a dropdown menu (same situation as above). How can I push data into the rows?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/a/2a0871d16aa4cd0073759f3db17d540e66a3749b.png)

---

<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 14, 2024, 6:26pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/8 "2024-01-14T18:26:36Z")

</div>

Dynamic UI datasets are typically generated either with a SQL query (binding) of some kind, usually with a transform, or a with a jython script.

You'll have to share your intentions as to how a user is expected to select what tags are of interest.

---

<div class="post-metadata">

**Author:** ![Vidar\_Hetlelid](https://avatars.discourse-cdn.com/v4/letter/v/dfb087/32.png) [@Vidar\_Hetlelid](https://forum.inductiveautomation.com/u/Vidar_Hetlelid)\
**Post date:** [January 14, 2024, 7:05pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/9 "2024-01-14T19:05:49Z")

</div>

Allright, so the intension is that i recieve 5 string arrays from MQTT. Each array should have its own column. The number of rows is dependent on how many values there is inside the arrays. Hope this makes sence.

I also want the table height to be adjusted according to the number of rows.

---

<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 14, 2024, 7:08pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/10 "2024-01-14T19:08:02Z")

</div>

> [@Vidar\_Hetlelid](#):
>
> Hope this makes sence.

Nope.

Please explain, with examples, the entire data flow, **and** what the user of your system will do.

---

<div class="post-metadata">

**Author:** ![Vidar\_Hetlelid](https://avatars.discourse-cdn.com/v4/letter/v/dfb087/32.png) [@Vidar\_Hetlelid](https://forum.inductiveautomation.com/u/Vidar_Hetlelid)\
**Post date:** [January 14, 2024, 7:45pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/11 "2024-01-14T19:45:27Z")

</div>

Allright, so, the user can manage brewing recipes in a separate system. This system has an API, and this data is sorted in node-red, then published to MQTT, which ignition subscribes to.

An example recipe looks like this. Where the columns are: amount, name, percent, type and color.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/6/a6041efa57ab5f4d95816392517234202127eada.png)

The number of different ingredients will vary depending on the recipe. In ignition I want to list all the ingredients the same way in a table.

So, i get a array of string for each of those colomns. So, if there are 4 different ingredients as in the example above, i get those arrays:

["2","2","0.57","0.1"]  
["Pale Ale Best Malz", "Pilsen BestMalz", "Caramel Pils BestMalz", "Pale Crystal Malt Thomas Fawcett"]  
etc....

Therefore the number of rows, should be dependent on the number of variables in the array.

---

<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 14, 2024, 8:16pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/12 "2024-01-14T20:16:15Z")

</div>

So, not really a table display question at all.

You have tags with arrays of values that are desired columns. You want to make a dataset with these columns. The python `map()` function is probably the right tool. Your python library function will look something like this:

```auto
columnTags = ['amount', 'name', 'type', 'color']

# tagFolder should be something like "[mqttProvider]path/to/recipe/folder"
def getDatasetFromArrayTags(tagFolder):
	paths = [tagFolder+'/'+c for c in columnTags]
	qvList = system.tag.readBlocking(paths)
	if all(qv.quality.good for qv in qvList):
		columnArrays = [qv.value for qv in qvList]
		return system.tag.toDataSet(columnTags, map(None, *columnArrays))
	# Any bad quality yields no dataset
	return None

```

The `map()` function with a `None` conversion function is effectively the same as python's `zip()` function, except that it will extend columns with `None` to make the columns all the same length, while `zip()` uses the shortest column.

---

<div class="post-metadata">

**Author:** ![Vidar\_Hetlelid](https://avatars.discourse-cdn.com/v4/letter/v/dfb087/32.png) [@Vidar\_Hetlelid](https://forum.inductiveautomation.com/u/Vidar_Hetlelid)\
**Post date:** [January 14, 2024, 9:21pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/13 "2024-01-14T21:21:45Z")

</div>

Thank you very much for helping me out here. Im not sure where I should write this code?

---

<div class="post-metadata">

**Author:** ![Vidar\_Hetlelid](https://avatars.discourse-cdn.com/v4/letter/v/dfb087/32.png) [@Vidar\_Hetlelid](https://forum.inductiveautomation.com/u/Vidar_Hetlelid)\
**Post date:** [January 20, 2024, 3:58pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/15 "2024-01-20T15:58:28Z")

</div>

Hi there,

Should this be made as a seperate script? Or should this be written on the table component? Im a little confused here, sorry

---

<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 20, 2024, 5:01pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/16 "2024-01-20T17:01:13Z")

</div>

Place the code I wrote in a project library script.

On the table where you want to display this, use an expression binding like so:

```auto
runScript('path.to.script.getDatasetFromArrayTags', 0, {path.to.folder.path.prop})

```

As shown, the code will run once at view startup, and again any time the folder path property changes. If you want it to run repeatedly, change the zero to some number of milliseconds between executions.

---

<div class="post-metadata">

**Author:** ![Vidar\_Hetlelid](https://avatars.discourse-cdn.com/v4/letter/v/dfb087/32.png) [@Vidar\_Hetlelid](https://forum.inductiveautomation.com/u/Vidar_Hetlelid)\
**Post date:** [January 20, 2024, 5:46pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/17 "2024-01-20T17:46:54Z")

</div>

Thank you, and sorry for alot of stupid questions here.. But i'm very lost at this...

I'm now using OPCUA, and the tag folder should be default/Brewfather\_OPCUA. But I can't see how I can sort out the columns I want to show in table.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/b/0b05ebb7550bb416d3ca27a5d25dc06adb4b5e54.jpeg)

And, what folder should this be?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/b/fbfdbcf915017e4d561d01bc28229c43e196f6f5.png)

---

<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 20, 2024, 5:58pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/18 "2024-01-20T17:58:22Z")

</div>

Couple points:

- The sample code is to be entered into a script module **verbatim**. Do **not** try to place a value in the `def` for `tagFolder`. `tagFolder` is an argument (a type of variable) that comes from the function's **caller**.

- The **caller** is the [runScript](https://docs.inductiveautomation.com/display/DOC81/runScript) function, and the argument is supplied by some string property in your UI that contains the folder path. Spend some time with the docs to understand how `runScript` works.

- When you create that string property, you can supply a static value for the moment as `[default]Brewfather_OPCUA`. (In code, strings like this need to be quoted, btw.)

- Your column names are different from mine. You will have to change `columnTags` to match your real tag names: `arMaltAmount`, ...

Side note: Have you gone through Inductive University? It is vital for newcomers.

---

<div class="post-metadata">

**Author:** ![Vidar\_Hetlelid](https://avatars.discourse-cdn.com/v4/letter/v/dfb087/32.png) [@Vidar\_Hetlelid](https://forum.inductiveautomation.com/u/Vidar_Hetlelid)\
**Post date:** [January 20, 2024, 6:29pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/19 "2024-01-20T18:29:39Z")

</div>

Well okay, so I can't use the script as is, I need to install a module for this script? I seached [inductiveautomation.com](http://inductiveautomation.com) and cannot find this module?

---

<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 20, 2024, 6:32pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/20 "2024-01-20T18:32:26Z")

</div>

No 3rd-party module required. In the designer, go to the "Scripting" node in the tree. Create a named **script module**. Place the sample code there.

---

<div class="post-metadata">

**Author:** ![Vidar\_Hetlelid](https://avatars.discourse-cdn.com/v4/letter/v/dfb087/32.png) [@Vidar\_Hetlelid](https://forum.inductiveautomation.com/u/Vidar_Hetlelid)\
**Post date:** [January 20, 2024, 6:34pm UTC](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243/21 "2024-01-20T18:34:05Z")

</div>

> [@pturmel](#):
>
> o 3rd-party module required. In the designer, go to the "Scripting" node in the tree. Create a named **script module**. Place the sample code there.

Isn't that what I've done here? Or is it not supported in maker edition?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/8/380e5783e641b0e451249c1bd6ec8882718b2ecd.png)

[Next page](https://forum.inductiveautomation.com/t/how-to-create-dataset-from-tags/84243.md?page=2)
