Skip to main content
RSS feed Subscribe to feed


Skip Navigation LinksHome  Extending the Spotfire Platform  Common Tasks and Idioms  Spotfire Axis Formatting  Cross Table with Measure Formatting

©Spotfire 2011

Cross Table with Measure Formatting

This example creates a cross table where a measure has been formatted as currency.

Requires Spotfire 2.2.

 // Cross table setup is assumed.
 // Set rows by Type.
 crossTable.RowAxis.Expression = "<Type>";

 // Set columns by Category.
 crossTable.ColumnAxis.Expression = "<[Category] NEST [Axis.Default.Names]>";

 // Set the values to Sum(Sales) and Count().
 crossTable.MeasureAxis.Expression = "Sum(Sales), Count()";

 // Create a currency formatter.
 NumberFormatter formatter = (NumberFormatter)DataType.Real.CreateFormatter();

 // Set the category to currency.
 formatter.Category = NumberFormatCategory.Currency;

 // Set the number of decimals to 2 and use $ as currency symbol.
 formatter.DecimalDigits = 2;
 formatter.CultureInfo = new System.Globalization.CultureInfo("en-US");

 // Set the formatter for the Sum(Sales) columns.
 crossTable.Formatting.IndexedRealFormatter["Sum(Sales)"] = formatter;

 // Create a number formatter.
 NumberFormatter nf = (NumberFormatter)DataType.Integer.CreateFormatter();

 // Set the category to general.
 nf.Category = NumberFormatCategory.General;

 // Set the formatter for the Count columns.
 crossTable.Formatting.IndexedIntegerFormatter["Count()"] = nf;