Working with OLAP Data

Analysis Services Programming

Analysis Services Programming

Working with OLAP Data

When working with OLAP data, it is possible to retrieve that data in two different forms: datasets and flattened rowsets. Datasets store the results of a query in an axis structure that is determined by the shape of the results. Flattened rowsets have only two axes. In this case, the data in the additional axes are stored by mapping them onto the two existing axes.

Multidimensional DataSets

A dataset is a multidimensional representation of the results of a Multidimensional Expressions (MDX) query. Each dimension that is returned by the query is represented in the dataset by an axis. The members of each dimension make up the coordinates on the axis. The measures are returned in cells. Each cell is located at the intersection of the coordinates along each axis.

In OLE DB for OLAP, the Dataset object provides methods for interacting with the axes and cells the dataset contains. The primary interface for working with the Dataset object is IMDDataset. Using this interface it is possible to retrieve the value of a cell (IMDDataset::GetCellData), retrieve a pointer to the Command object interface that created the cellset(IMDDataset::GetSpecification), or retrieve information about the axes(IMDDataset::FreeAxisInfo, IMDDataset::GetAxisInfo, IMDDataset::GetAxisRowset). For more information, see the OLE DB documentation.

In Microsoft® ActiveX® Data Objects (Multimensional) (ADO MD), the Cellset object contains a collection of cells, axes and properties. To access an individual cell in the cellset, use the Item() method. Cells can be specified by providing one of the following:

  • The position numbers of the cell.

  • The member names (that is, the tuple) for the cell.

  • The ordinal position of the cell.

For more information, see the ADO MD documentation.

Flattened Rowsets

Whenever the results of an MDX query that returns data on more than two axes must be represented in two dimensions, such as in an OLE DB Rowset object or an ADO Recordset object, the results must be mapped onto the two dimensions using a process called flattening. For more information about flattening rowsets, see the OLE DB for OLAP documentation.

In OLE DB, the Rowset object exposes the results of a query (either MDX or SQL) in a tabular form. It is represented by a set of rows. Each row contains a set of columns that contain the data returned from the query. The primary interface for interacting with Rowset objects is the OLE DB IRowset interface. In addition to this interface, the following helper interfaces are used to navigate through the rowsets: IAccessor, IColumnsInfo, IConvertType, and IRowsetInfo. For more information, see the OLE DB documentation.

In ADO, the Recordset object represents the results of a query in tabular form. Each Recordset object consists of a collection of Fields and Properties. The IMDDataset:: collection represents the columns in the query results. The Properties collection contains the properties that describe the rowset. ADO provides numerous methods and objects for navigating through returned recordsets.

Note  Because recordsets that contain flattened rowsets are read-forward only, Recordset object methods such as MoveFirst, MovePrevious, and RecordCount return the error 0x80004001 – Not Implemented.

For more information, see the ADO documentation.