ComponentOne Olap for WinForms
OLAP for WinForms Task-Based Help / Formatting Numeric Data
In This Topic
    Formatting Numeric Data
    In This Topic

    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:

    1. Right-click a field in the Values area of the C1OlapPanel.
    2. Click Field Settings in the context menu. The Field Settings dialog box opens.
    3. Click the Format tab.
    4. Select one of the following options:
      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.

    5. Click OK to close the Field Settings dialog box. Notice how the values in the summary table change.

    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";