A quick Google search turned up this code:
from Spotfire.Dxp.Application.Visuals import *
#Script Parameter
myVis = myVis.As[Visualization]()
#Show grand total for rows (not needed if creating toggle)
myVis.ShowRowGrandTotal = True
#How to toggle
if myVis.ShowRowGrandTotal == False:
myVis.ShowRowGrandTotal = True
else:
myVis.ShowRowGrandTotal = False
Reference: https://www.sf-ref.com/ironpython/visualizations/cross-table/appearance/
Attach that script to a button or some kind of action and you are good to go.