To render the mapping of tuple ordinals to cell ordinals, as you would want to do in a client application displaying the results of your MDX query, you use a formula. Given a set of tuple ordinals, S in a p-dimensional data set, where each dimension, k, has M members, you use the following formula to calculate the ordinal:

Although this formula looks imposing on paper, in practice it isn’t difficult to work through. Imagining the data as presented in a row-major matrix makes the task a lot easier. As an example, let’s calculate some ordinals for the CellData from a two-dimensional query that has three members for each dimension, as Web Listing A shows.

First, let’s figure out what the value of the top-left result is. The coordinates of the top left element are 0,0 (first column, first row in a zero-based matrix), so we have S0 = 0 and S1 = 0. We also know that we have two dimensions, so p = 2, and we have three members in each dimension, so M0 = 3 and M1 = 3. Plugging those numbers into the formula, we get the following ordinal:

Looking for a value for CellOrdinal 1 in the CellData, we don’t find any value, so we use the default value if specified or null if there’s no default value.

Next, let’s calculate the value for the 2,1 element (third column, second row in a zero-based matrix). We have S0 = 2 and S1 = 1. The values for p and M are the same as before—2 and 3. Using the formula, we get:

Looking in CellData, you'll find the value 191940 for CellOrdinal 5, which you can use for presentation or further calculations. As you can see from these examples, mapping the results of a XMLA tuple is straightforward, and you can apply the formula to any XMLA analytical application you create that needs to access the values from an MDX query