# How to calculate sum of variable and move to global data

**URL:** https://discourse.paraview.org/t/how-to-calculate-sum-of-variable-and-move-to-global-data/10552
**Category:** ParaView Support
**Created:** [October 20, 2022, 12:49am UTC](https://discourse.paraview.org/t/how-to-calculate-sum-of-variable-and-move-to-global-data/10552 "2022-10-20T00:49:25Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![wascott](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/8e8cbc/32.png) [@wascott](https://discourse.paraview.org/u/wascott)
#### Post date: [October 20, 2022, 12:49am UTC](https://discourse.paraview.org/t/how-to-calculate-sum-of-variable-and-move-to-global-data/10552/1 "2022-10-20T00:49:25Z")

</div>

Hi everyone,  
I have a user that is trying to do calculations on point (or cell) data, and then move the result into a global variable. For instance, the user wants to do the following:

**# Code for ‘Script’**

**# ‘inputs’ is set to an array with data objects produced by inputs to**

**# this filter.**

**# Get the first input.**

input0 = inputs[0]

**# compute a value.**

dataArray = sum(input0.PointData[“V”])

**# ‘output’ is a variable set to the output dataset.**

output.FieldData.append(dataArray, “V\_sum”)

Any idea how do do this?

Thanks, Alan

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [October 20, 2022, 12:55am UTC](https://discourse.paraview.org/t/how-to-calculate-sum-of-variable-and-move-to-global-data/10552/2 "2022-10-20T00:55:43Z")

</div>

I dont see anything wrong with that code. At first glance, it should work.

---

<div class="post-metadata">

### Author: ![wascott](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/8e8cbc/32.png) [@wascott](https://discourse.paraview.org/u/wascott)
#### Post date: [October 20, 2022, 12:57am UTC](https://discourse.paraview.org/t/how-to-calculate-sum-of-variable-and-move-to-global-data/10552/3 "2022-10-20T00:57:33Z")

</div>

Obviously, code is from user. Let me try it.
