I am trying to get the difference of the status and goal column and place it in the Behind/ Ahead column. I have looked into the system.dataset functions, but I do not see any mathematical equations within the manual. This is the screenshot below, I am using a regular table form the component palette in vision.
Currently it is just through the dataset. I made the table editable and they would input the values within the weekly needs, status and goal. The remaining and Behind/ ahead would be calculated for them. Each row in my table will have differing data, not sure if that would mess up the custom property idea!
Not at all, though make sure you make the calculated columns un-editable. Though there really isn't a need for a custom property if your data is only ever going to reside in the table, and you don't need to keep a copy of the unmodified dataset.
Also, user data entry should be validated, so I would probably use the cellEdited event on the table to validate the data entry and then an external component to have the user trigger an update to the table when all the data has been entered.
So for instance you might place this script in a Button's actionPerformed script.
#get data from table
data = event.source.parent.getComponent('YourTableName').data
#convert data to a pyDataSet (technically not requiered but makes working with the data much easier
pyData = system.dataset.toPyDataSet(data)
#loop through each row and do calculations
for row in pyData:
row['Behind / Ahead'] = row['Goal'] - row['Status']
#update the table with the new dataset
event.source.parent.getComponent('YourTableName').data = system.dataset.toDataSet(pyData)
If you are looking to keep it inside the table, then consider using a power table instead. It will give you more options. Here’s a window you can play with.
Thank you so much! That seemed as though it would work but it does say
Traceback (most recent call last):
File "event:actionPerformed", line 9, in
TypeError: com.inductiveautomation.ignition.common.script.builtin.DatasetUtilities$PyDataSet$PyRow indices must be integers
I went ahead and tried @JordanCClark solution which worked!