# Add a unit of the data in the cell of the DATASET

**URL:** <https://forum.inductiveautomation.com/t/add-a-unit-of-the-data-in-the-cell-of-the-dataset/82233>\
**Category:** Ignition\
**Created:** [November 22, 2023, 1:49am UTC](https://forum.inductiveautomation.com/t/add-a-unit-of-the-data-in-the-cell-of-the-dataset/82233 "2023-11-22T01:49:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ignitionSL](https://avatars.discourse-cdn.com/v4/letter/i/9e8a1a/32.png) [@ignitionSL](https://forum.inductiveautomation.com/u/ignitionSL)\
**Post date:** [November 22, 2023, 1:49am UTC](https://forum.inductiveautomation.com/t/add-a-unit-of-the-data-in-the-cell-of-the-dataset/82233/1 "2023-11-22T01:49:50Z")

</div>

How to add units to every data in a DATASET?  
Here I retrieve the dataset from the database. I need to add the 'units' in each data.

Is there anyway that I can round up the decimal points?

Here is the example dataset.

```auto
[{"Inve_No":2,"t_stamp":1700616850425,"RealPower":1118.932861328125,"ReactivePower":20.764755249023438,"CB_Status":true,"CB_OpenCmd":false,"Frequency":49.5400505065918,"CB_CloseCmd":false,"DC_Current":25.600000381469727,"DC_Power":450.29998779296875}]

```

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [November 22, 2023, 2:18am UTC](https://forum.inductiveautomation.com/t/add-a-unit-of-the-data-in-the-cell-of-the-dataset/82233/2 "2023-11-22T02:18:06Z")

</div>

When you get it and edit it, will it actually be a dataset datatype, or will it be in the json format you've posted?

---

<div class="post-metadata">

**Author:** ![ignitionSL](https://avatars.discourse-cdn.com/v4/letter/i/9e8a1a/32.png) [@ignitionSL](https://forum.inductiveautomation.com/u/ignitionSL)\
**Post date:** [November 22, 2023, 2:25am UTC](https://forum.inductiveautomation.com/t/add-a-unit-of-the-data-in-the-cell-of-the-dataset/82233/3 "2023-11-22T02:25:42Z")

</div>

YEs

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [November 22, 2023, 2:55am UTC](https://forum.inductiveautomation.com/t/add-a-unit-of-the-data-in-the-cell-of-the-dataset/82233/4 "2023-11-22T02:55:51Z")

</div>

> [@ignitionSL](#):
>
> Is there anyway that I can round up the decimal points?

With scripting on a dataset datatype, it can be done like this:

```auto
# originalDataset = Get the original dataset

# Get the headers from the dataset
headers = system.dataset.getColumnHeaders(originalDataset)

# Create a list for the the processed rows
newData = []

# Iterate through every row of the original dataset
for row in range(originalDataset.rowCount):

	# Create a list for the processed column values of each row
	newRow = []
	
	# Iterate through each column of each row, and get the values
	for column in range(originalDataset.columnCount):
		value = originalDataset.getValueAt(row, column)
		
		# If a value is a float, round it and apend it to the new row. Otherwise, just append it to the new row
		# ...The ", 0" in the round function means round to zero decimal places. This can be adjusted as needed.
		if isinstance(value, float):
			newRow.append(round(value, 0))
		else:
			newRow.append(value)
	
	# Append each fully processed row to the new data list
	newData.append(newRow)
	
# Convert the new data list to a dataset using the headers from the original dataset
newDataset = system.dataset.toDataSet(headers, newData)

```

---

<div class="post-metadata">

**Author:** ![ignitionSL](https://avatars.discourse-cdn.com/v4/letter/i/9e8a1a/32.png) [@ignitionSL](https://forum.inductiveautomation.com/u/ignitionSL)\
**Post date:** [November 22, 2023, 5:34am UTC](https://forum.inductiveautomation.com/t/add-a-unit-of-the-data-in-the-cell-of-the-dataset/82233/5 "2023-11-22T05:34:00Z")

</div>

Found the solution

```auto
units=['',' MW',' MVar','','',' Hz','',' A',' W'] # units for data
B = newdata.getColumnAsList(0) # select column data which need to add units
baz = [x+y for x, y in zip(B, units)] # Create new column adding units
for i in range (9):
	newdata = system.dataset.updateRow(newdata, i, {"Value 1": baz[i]})	#update the each row with the added units to the column data

```
