# Grand total at the last row of a table in Perspective table

**URL:** <https://forum.inductiveautomation.com/t/grand-total-at-the-last-row-of-a-table-in-perspective-table/71753>\
**Category:** General Discussion\
**Tags:** perspective\
**Created:** [March 29, 2023, 6:49am UTC](https://forum.inductiveautomation.com/t/grand-total-at-the-last-row-of-a-table-in-perspective-table/71753 "2023-03-29T06:49:43Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![kavya\_shree](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kavya\_shree](https://forum.inductiveautomation.com/u/kavya_shree)\
**Post date:** [March 29, 2023, 6:49am UTC](https://forum.inductiveautomation.com/t/grand-total-at-the-last-row-of-a-table-in-perspective-table/71753/1 "2023-03-29T06:49:43Z")

</div>

Hi,  
I want to show the grand total of all the columns in the last row of the Perspective Table.  
I have binded the table data with named query.  
here is the example:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/7/770142411a9a8da8bdad3ddc6cbea19613d471aa.png)

Please guide

Thank you

---

<div class="post-metadata">

**Author:** ![Richard\_Giske](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/richard_giske/32/41906_2.png) [@Richard\_Giske](https://forum.inductiveautomation.com/u/Richard_Giske)\
**Post date:** [March 29, 2023, 8:43am UTC](https://forum.inductiveautomation.com/t/grand-total-at-the-last-row-of-a-table-in-perspective-table/71753/2 "2023-03-29T08:43:46Z")

</div>

Add another script transform where you load the data  
Then sum one of the rows, then create a new row(in your case you'll need 3 columns in the new row, I got 2 in the example.  
Then the addRow function adds the new row at the bottom

```
NewSummedData= sum(value.getColumnAsList(1)) 
|---|---|
|newRow = [Summed Values,NewSummedData]
newdataset = system.dataset.addRow(value,newRow)
return newdataset

```

 ![bilde](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/9/c9401c4a446f647c33bef804ebb8ff363dff5283.png)

---

<div class="post-metadata">

**Author:** ![kavya\_shree](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kavya\_shree](https://forum.inductiveautomation.com/u/kavya_shree)\
**Post date:** [March 29, 2023, 9:25am UTC](https://forum.inductiveautomation.com/t/grand-total-at-the-last-row-of-a-table-in-perspective-table/71753/3 "2023-03-29T09:25:15Z")

</div>

Thank you

sorry but exactly I am not getting. this table I want to show on load page.

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

---

<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:** [March 29, 2023, 9:54am UTC](https://forum.inductiveautomation.com/t/grand-total-at-the-last-row-of-a-table-in-perspective-table/71753/4 "2023-03-29T09:54:17Z")

</div>

Do you have a sample of the data you can share?

---

<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:** [March 29, 2023, 10:14am UTC](https://forum.inductiveautomation.com/t/grand-total-at-the-last-row-of-a-table-in-perspective-table/71753/6 "2023-03-29T10:14:11Z")

</div>

Well, I was kind of hoping for the dataset, since that is what will be manipulated. 😉

---

<div class="post-metadata">

**Author:** ![kavya\_shree](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kavya\_shree](https://forum.inductiveautomation.com/u/kavya_shree)\
**Post date:** [March 29, 2023, 11:39am UTC](https://forum.inductiveautomation.com/t/grand-total-at-the-last-row-of-a-table-in-perspective-table/71753/7 "2023-03-29T11:39:17Z")

</div>

sorry I didn't get it. is this is what your asking

[sampledata.zip](https://forum.inductiveautomation.com/uploads/short-url/jSLF9GCw7tXBVDpVKsPawbaBSY8.zip) (8.3 KB)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/b/6bd2912b4b7b82ad2148ce97c6a74143764c45bf.png)

---

<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:** [March 29, 2023, 11:43am UTC](https://forum.inductiveautomation.com/t/grand-total-at-the-last-row-of-a-table-in-perspective-table/71753/8 "2023-03-29T11:43:12Z")

</div>

A copy of the dataset that populates this table. This is the one that you are looking for totals, correct? Also, do you need the shift totals, as well? as per your first post?  
 ![thumbnail](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/7/b7e32f32b5af45e6fad2b6783c72f5ed161709dd.png)

---

<div class="post-metadata">

**Author:** ![kavya\_shree](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kavya\_shree](https://forum.inductiveautomation.com/u/kavya_shree)\
**Post date:** [March 29, 2023, 11:57am UTC](https://forum.inductiveautomation.com/t/grand-total-at-the-last-row-of-a-table-in-perspective-table/71753/9 "2023-03-29T11:57:34Z")

</div>

yes I want total of TargetPerMonth column and actualYield column ie. 2nd and 3rd column  
last row I want to display total.

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

---

<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:** [March 29, 2023, 12:05pm UTC](https://forum.inductiveautomation.com/t/grand-total-at-the-last-row-of-a-table-in-perspective-table/71753/10 "2023-03-29T12:05:12Z")

</div>

The error you are seeing is because your new row does not have the same number of columns.

```python
targetPerMonthSum = sum(value.getColumnAsList(1)) 
actualYieldSum = sum(value.getColumnAsList(2))
newRow = ['Total', targetPerMonthSum, actualYieldSum]
newdataset = system.dataset.addRow(value,newRow)
return newdataset

```

---

<div class="post-metadata">

**Author:** ![kavya\_shree](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kavya\_shree](https://forum.inductiveautomation.com/u/kavya_shree)\
**Post date:** [March 30, 2023, 3:36am UTC](https://forum.inductiveautomation.com/t/grand-total-at-the-last-row-of-a-table-in-perspective-table/71753/11 "2023-03-30T03:36:06Z")

</div>

yes I am getting. I didn't have any idea of using Add Transform, need to learn lot in perspective.

Thank you Thank you so much. This is what I exactly I wanted.
