Oliver Drummond
Oliver Drummond

Reputation: 530

Spotfire How To Change Calculate Totals Using Iron Python

I have a Cross Table in my Spotfire Dashboard and am trying to change the "Calculate Totals" option using an Iron Python script.

enter image description here

I've found this link on Spotfire API. So, from what I understood, this information is stored in myVis.Totals. But, for whatever the reason, this seems to be a read-only property as can be seen here.

Have any of you ever had this problem and would know how to fix it?

This is my code:

from Spotfire.Dxp.Application.Visuals import *

# myVis is a script parameter of the type "Visualisation"
myVis = myVis.As[Visualization]()
myVis.Totals = CrossTableTotals.CalculationMode.SumOfCellValues

This is the error I'm getting:

Traceback (most recent call last):
  File "<string>", line 5, in <module>
AttributeError: can't assign to read-only property Totals of type 'CrossTablePlot'


System.MissingMemberException: can't assign to read-only property Totals of type 'CrossTablePlot'
   at CallSite.Target(Closure , CallSite , Object , Object )
   at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
   at Microsoft.Scripting.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame)
   at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
   at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
   at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)
   at Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope)
   at Spotfire.Dxp.Application.IronPython27.IronPythonScriptEngine.ExecuteForDebugging(String scriptCode, Dictionary`2 scope, Stream outputStream)

Upvotes: 0

Views: 544

Answers (1)

Gaia Paolini
Gaia Paolini

Reputation: 1452

Try this

myVis.Totals.DefaultCalculationMode=CrossTableTotals.CalculationMode.SumOfCellValues

Gaia

Upvotes: 3

Related Questions