# Convert a string to int in the dataset

**URL:** <https://forum.inductiveautomation.com/t/convert-a-string-to-int-in-the-dataset/66964>\
**Category:** Ignition\
**Tags:** database, scripting, perspective\
**Created:** [November 28, 2022, 9:47am UTC](https://forum.inductiveautomation.com/t/convert-a-string-to-int-in-the-dataset/66964 "2022-11-28T09:47:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![saravanan\_Manickam](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@saravanan\_Manickam](https://forum.inductiveautomation.com/u/saravanan_Manickam)\
**Post date:** [November 28, 2022, 9:47am UTC](https://forum.inductiveautomation.com/t/convert-a-string-to-int-in-the-dataset/66964/1 "2022-11-28T09:47:02Z")

</div>

perspective-report-scrpit  
rawDataset = data['named\_query'].getCoreResults()  
data[a] = str(rawDataset.getValueAt(0,'TotalLoss')) // 107 3--value  
data[b] = str(rawDataset.getValueAt(1,'TotalLoss')) // 109 2--value

I need to add the a & b but cannot able to add  
because a is the string cannot able to convert a into int

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [November 28, 2022, 10:14am UTC](https://forum.inductiveautomation.com/t/convert-a-string-to-int-in-the-dataset/66964/2 "2022-11-28T10:14:15Z")

</div>

Try removing the str function (that coerces things into strings).

---

<div class="post-metadata">

**Author:** ![saravanan\_Manickam](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@saravanan\_Manickam](https://forum.inductiveautomation.com/u/saravanan_Manickam)\
**Post date:** [November 28, 2022, 11:02am UTC](https://forum.inductiveautomation.com/t/convert-a-string-to-int-in-the-dataset/66964/3 "2022-11-28T11:02:30Z")

</div>

yeah i tried But ,

d = (data[a])+(data[b])  
data[d] = d

the **result** is coming as = **10731092** only but the expected output is 2163

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [November 28, 2022, 11:10am UTC](https://forum.inductiveautomation.com/t/convert-a-string-to-int-in-the-dataset/66964/4 "2022-11-28T11:10:45Z")

</div>

Then I'm guessing those are already strings, and using `+` concatenates them.  
Convert to integers before adding, with `int()`

---

<div class="post-metadata">

**Author:** ![saravanan\_Manickam](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@saravanan\_Manickam](https://forum.inductiveautomation.com/u/saravanan_Manickam)\
**Post date:** [November 28, 2022, 11:17am UTC](https://forum.inductiveautomation.com/t/convert-a-string-to-int-in-the-dataset/66964/5 "2022-11-28T11:17:23Z")

</div>

i think so it's works
