Appendix D. Format String Codes

Calculated members and cell calculations can specify the formatting applied to a cell value to transform it into a formatted value. The formatted value is a text string, whereas the raw value can be numeric or textual (and a numeric cell could represent a date or time serial number). This appendix lays out the codes specified by OLE DB for OLAP and used by Microsoft's OLAP, Analysis Services 2000, and Analysis Services 2005. The codes match the format arguments used by the Visual Basic Format() function.

Formatting Numeric Values

A format expression for numeric values can have from one to four sections, each section separated by semicolons. If the format argument contains one of the named numeric formats, only one section can be used. Table D-1 lists the section usage and interpretations of sections in format strings.

The following example has one section, and formats a number with two decimal places:

"#.00"

Table D-1. Format String Sections and Interpretations

SECTION USAGE

INTERPRETATION

One section

The format expression applies to all values.

Two sections

The first section applies to positive values and zeros, the second to negative values.

Three sections

The first section applies to positive values, the second to negative values, and the third to zeros.

Four sections

The first section applies to positive values, the second to negative values, the third to zeros, and the fourth to null values.

The following example has two sections. The first section defines the ...

Get MDX Solutions: With Microsoft® SQL Server™ Analysis Services 2005 and Hyperion® Essbase, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.