Adding a boolean column to multiple datasets


I have 20 different dataset tags that I would like to write to a template that holds a powertable. I would then like to display those powertables in a template repeater. Currently I have two string columns on my dataset tags and would like to add a third column that will just be a boolean check box for each row. I have my data section binded to my dataset tags through an indirect binding that looks like this Projects/Test/{1}/tagname and am then connecting it to where my Ref # 1 = custom property I set up on my page. Currently I can see the two columns just fine.

My question is how can I add a third column which is a boolean datatype to my preexisting dataset tags? I would like my end tag to have 3 columns in total (the two already there + the new column). I thought about using the system.dataset.addColumn but was unsuccessful.


Since they are tags, you will need to write to the tags if you are wanting to do this from script.

The flow would be something like this:

1.) Read tag
2.) Modify Dataset adding column
3.) Write new value back to tag

Otherwise, you will need to edit the tag from the designer and add the column there.

No, don’t do this. By “this”, I mean writing back to the same tag. There will be constant clashes between the expression/SQL that yields the two column form and the code that adds the third column. Plus, the third column is for use in a UI. In this case, the template should be passed the tag path to the source dataset in a public string property. An internal property would indirect bind to retrieve the source dataset, and the power table would have its data property bound to a runScript() expression that adds the third column.

1 Like

Hey Phil,

What would the runScript() look like? Sorry I am still learning Ignition and am a newbie to scripting.

There are two runScript() modes: a one-line python expression to evaluate, or a one-line string naming a python callable function. The latter will take any extra arguments to runScript(), after the poll time, and pass them to the callable. Ideally, you’d just be able to have your binding expression look like this:

runScript("system.dataset.addColumn", 0, {}, [], 'someColumn', bool)

Unfortunately, there’s no way to represent the list or the bool datatype in Ignition’s binding expressions.

There are two solutions:

  1. Create a project script that supplies everything except the source data
def addBoolColumn(sourceDS):
    return system.dataset.addColumn(sourceDS, sourceDS.columnCount, [False] * sourceDS.rowCount, 'BoolColumn', bool)

and call that from runScript:

runScript("project.someModule.addBoolColumn", 0, {})

Or, instead,

  1. Use objectScript(), from my Simulation Aids module (free!). And you can make a one-liner like so:
objectScript("system.dataset.addColumn(args[0], args[0].columnCount, [False] * args[0].rowCount, 'BoolColumn', bool)",

objectScript() offers the convenient complete one-line execution of an expression like runScript, yet includes the ability to pass arguments. And exposes some other features not available in runScript.

{ Edited to add the missing poll times to the runScript expressions }

I guess you have inferred more information from the OP than I did, because, all I saw was dataset tags, nothing about those tags being the result of an expression/SQL query. My assumption was then that the dataset was created manually. Perhaps a poor assumption on my part, and I should have asked for more information.

My apologies for any mis-information

I inferred it from his desire to put all of this in a template repeater, which would need bindings to get the source datasets.

Hi lrose,

I am using dataset tags and am not getting those tags from an expression/SQL query. The dataset is being pulled manually as you assumed earlier.

Hi Phil,

Will I be calling the runScript ('project.someModule.addBoolColumn",0,{}) from the data binding on the power table? Or will I be calling this from another place since I wasn’t sure if I can bind both a indirect tag binding as well as an expression binding.

A couple more questions:

1.) When you say the dataset is being pulled manually, does that mean that these are memory tags and you added the data by hand?
2.) Are you just looking for a quick way to add the extra column to all of the datasets (one time script), or do you want to only add the column inside of the template (the tags are being used in other places as is and that isn’t changing)?


You can’t, but you don’t need to. The table’s data property won’t be bound to the two-column dataset. The indirect binding (to the two-column dataset) is on a template internal (private) custom property. The indirect would use the tagpath string that is provided in a template public custom property.

The data is being stored on a memory tag but I am taking the information from another tag. Yeah I would like to add the extra column to all of my datasets since I can then just reference the new dataset tag with three columns in my template.

How are you taking the data from another tag? If the data is being written from another place into these 20 dataset tags, then that is where, I personally would look at making a modification.