First you need to extract the data. For example:
E2=getelectric("monitor");
this is the electric intensity.
then you can sum them using
E2sum=sum(E2). It will sum up all the data into one value.
Not sure what is the physical meaning of this operation.
There vidoes for scripting:
https://optics.ansys.com/hc/en-us/sections/360007813714-SCRIPTING100-List-of-videos
articles: https://optics.ansys.com/hc/en-us/categories/360001998954-Scripting-Language