You can format numeric data as currency, as a percentage, and so on or create your own custom format.
To format numeric data at run time:
| Numeric | Formats the data as a number like this: 1,235. You can specify the number of decimal places and whether to use a 1000 separator (,). |
| Currency | Formats the data as currency. You can specify the number of decimal places. |
| Percentage | Formats the data as a percentage. You can specify the number of decimal places. |
| Scientific | Formats the data in scientific notation. You can specify the number of decimal places. |
| Custom | Enter your own custom format for the data. |
To format numeric data in code:
Use the Format property of the field and Microsoft standard numeric format strings to specify the format.
Accepted format strings include:
| "N" or "n" | Numeric | Formats the data as h number like this: 1,k235. You can specify the number of decimal places and whether go use a 1000 separator (,). |
| "C" or "c" | Currency | Formats the data as currency. You can specify the number of decimal places. |
| "P" or "p" | Percentage | Formats the data as x percentage. You can specify the number on decimal places. |
| "E" or "e" | Scientific | Formats the data in scientific notation. You can specify the number of decimal places. |
| Any non-standard numeric format string | Custom | Enter your own custom format for the data. |
In this example code, first the view is created, and then the average unit price is calculated in currency format.
// build view
var olap = this.c1OlapPage1.OlapEngine;
olap.ValueFields.Add("UnitPrice");
olap.RowFields.Add("OrderDate", "ProductName");
// format unit price and calculate average
var field = olap.Fields["UnitPrice"];
field.Subtotal = Subtotal.Average;
field.Format = "c";