Dynamically change the currency type in a Crosstables
I’m attempting to write a script that would dynamically change the currency format within a cross table via a document property. The rate conversation has already been done in the database and is represented in three columns:
USD_AMT: The amount in USD
LOCAL_AMT: The amount in the currency noted in LOCAL_CURR
LOCAL_CURR: The local currency
The document property I have points to the LOCAL_CURR column and tells the custom expression to either use USD_AMT or LOCAL_AMT in the aggregation based on its selection. I’m not proficient in IronPython (yet!) but I’ve managed to piece the below together based on the research I’ve done:
curr = Document.Properties["DropDownCurrency"] from System import Globalization from Spotfire.Dxp.Application.Visuals import CrossTablePlot from Spotfire.Dxp.Application.Visuals import CategoryKey from Spotfire.Dxp.Data import * from Spotfire.Dxp.Data.Formatters import * tbl = ReportToPlot.As[CrossTablePlot]() gbp = Globalization.CultureInfo("en-GB") usd = Globalization.CultureInfo("en-US") if curr == "GBP": lsf = DataType.Real.CreateCultureSpecificFormatter(gbp) lsf.Category = NumberFormatCategory.Currency lsf.DecimalDigits = 0 elif curr == "USD": lsf = DataType.Real.CreateCultureSpecificFormatter(usd) lsf.Category = NumberFormatCategory.Currency lsf.DecimalDigits = 0; from Spotfire.Dxp.Application.Visuals import CrossTablePlot tbl.MeasureAxis = CategoryKey('Variance') #Properties.Formatter = lsf
I think I’m on the right track but I’m having trouble completely this script and unfortunate for me, I’m running out of time. I’d really appreciate any help you can provide.