Excluding Empty Cells
The
elimination of empty cells is a mere keyword away. We will accomplish our
objective in the steps that follow:
1.
Within the
query we have saved as MDX17-1, add the EXCLUDEEMPTY keyword to
the Count() function, separated by a comma from the existing specified
set, as shown:
'Count( {[Store Type].[Store Type].MEMBERS },
EXCLUDEEMPTY)'
2.
Replace the
top comment line of the query with the following:
-- MDX17-2: Counting that excludes Empty Cells
The
Query pane
appears as shown in Illustration 4.
3.
Execute the
query by clicking the Run Query button in the toolbar.
The
Results pane is
populated, and the dataset shown in Illustration 5 appears. We see that
the counts drop to two, five and five, for the Canada, Mexico and USA Store
Types, respectively.
Illustration 5: Result
Dataset - Count() with EXCLUDEEMPTY Flag in Place
4.
Save the file
as MDX17-2.
Let's
tidy things up a bit by ordering our results dataset based upon the
counts we have obtained.
5.
Within the
query we have saved as MDX17-2, make the following change to the ON
ROWS portion of the SELECT section of the query, as shown:
Change:
{ [Store].[Store Country].MEMBERS } ON ROWS
To:
{ORDER ( [Store].[Store Country].MEMBERS,
[Store Type].[Types Count] , BDESC ) } ON ROWS
6.
Replace the
top comment line of the query with the following:
-- MDX17-3: Ordering the Row Axis
The
Query pane
appears as shown in Illustration 6.
Illustration 6: The Query with Modifications Circled
7.
Execute the
query by clicking the Run Query button in the toolbar.
The
Results pane is
populated, and the dataset shown in Illustration 7 appears. The results
are ordered by Types Count, largest to smallest.
Illustration 7: Result Dataset - Ordered by Types Count
(Descending)
NOTE: For a tutorial surrounding the Order()
function, see MDX
Essentials: Basic Set Functions: The Order() Function.
8.
Save the file
as MDX17-3.
We
appear to have attained our objective. One more step, near and dear to the
hearts of those who wish to ensure the quality of their work, and particularly
to recovering CPA's like myself, is a test of accuracy and completeness. Let's
look at the answer we are about to give Finance from another perspective - and
at the same time look ahead to the subject of our next lesson, the CrossJoin()
function.