Database Reference
In-Depth Information
Alternatively, the
NON EMPTY
keyword can be used as in the following
query:
SELECT Measures.MEMBERS ON COLUMNS,
NON EMPTY Customer.Country.MEMBERS ON ROWS
FROM Sales
Although in this case the use of the
NONEMPTY
function and the
NON
EMPTY
keyword yields the same result, there are slight differences between
both, which go beyond this introduction to MDX.
Notice also that the derived measure
NetAmount
does not appear in the
result. If we want this to happen, we should use the
ALLMEMBERS
keyword:
SELECT Measures.ALLMEMBERS ON COLUMNS,
Customer.Country.MEMBERS ON ROWS
FROM Sales
The
ADDCALCULATEDMEMBERS
function can also be used for this purpose.
6.1.3 Slicing
Consider now the query below, which shows all measures by year:
SELECT Measures.MEMBERS ON COLUMNS,
[Order Date].Year.MEMBERS ON ROWS
FROM Sales
The query returns the following result:
Unit Price Quantity Discount Sales Amount
Freight
Sales Count
All
$134.14
46,388
27.64% $1,145,155.86 $58,587.49
1,931
1996
$99.55
8,775
21.95%
$191,849.87
$9,475.00
371
1997
$116.63
23,461
25.89%
$570,199.61 $29,880.49
982
1998
$205.38
14,152
35.74%
$383,106.38 $19,232.00
578
To restrict the result to Belgium, we can write the following query:
SELECT Measures.MEMBERS ON COLUMNS,
[Order Date].Year.MEMBERS ON ROWS
FROM Sales
WHERE (Customer.Country.Belgium)
The added condition does not change what is returned on the axes (i.e., the
years and the measure names), but only the values returned in each cell. In
this example, the query returns the values of all measures for all years but
only for customers who live in Belgium.
Multiple members from
different
hierarchies can be added to the
WHERE
clause. The following query shows the values of all measures for all years
Search WWH ::
Custom Search