The data that is used in these
simple examples is from a company that sells various makes and models
of cars. The company needs to report sales figures for different months.
Example of a simple two-dimensional query:
SELECT
{ [cars].[all cars].[chevy], [cars].[all cars].[ford] } ON COLUMNS,
{ [date].[all date].[march], [date].[all date].[april] } ON ROWS
FROM mddbcars
Example of how you can flip the rows and columns:
SELECT
{ [cars].[all cars].[chevy], [cars].[all cars].[ford] } ON ROWS,
{ [date].[all date].[march], [date].[all date].[april] } ON COLUMNS
FROM mddbcars
Example of selecting a different
measure (sales_n) to be the default:
SELECT
{ [cars].[all cars].[chevy], [cars].[all cars].[ford] } ON COLUMNS,
{ [date].[all date].[march], [date].[all date].[april] } ON ROWS
FROM mddbcars
WHERE ([measures].[sales_n])
Example of using ":" to get a
range of members:
SELECT
{ [cars].[all cars].[chevy], [cars].[all cars].[ford] } ON COLUMNS,
{ [date].[all date].[january] : [date].[all date].[april] } ON _ROWS
FROM mddbcars
Example of the .MEMBERS function:
SELECT
{ [cars].[all cars].[chevy], [cars].[all cars].[ford] } ON COLUMNS,
{ [date].members } ON ROWS
FROM mddbcars
example of the .CHILDREN function:
SELECT
{ [cars].[all cars].[ford].children } ON COLUMNS,
{ [date].members } ON ROWS
FROM mddbcars
Example of selecting
more than one dimension in a tuple:
SELECT
{ ( [cars].[all cars].[chevy], [measures].[sales_sum] ),
( [cars].[all cars].[chevy], [measures].[sales_n] ),
( [cars].[all cars].[ford], [measures].[sales_sum] ),
( [cars].[all cars].[ford], [measures].[sales_n] )
} ON COLUMNS,
{ [date].members } ON ROWS
FROM mddbcars
Example of how the CROSSJOIN function makes tuple combinations
for you:
SELECT
{ CROSSJOIN ( { [cars].[all cars].[chevy], [cars].[all cars].[ford] },
{ [measures].[sales_sum], [measures].[sales_n] } )
} ON COLUMNS,
{ [date].members } ON ROWS
FROM mddbcars
Example of using the NON_EMPTY keyword to discard the
row with no sales:
SELECT
{ CROSSJOIN ( { [cars].[all cars].[chevy], [cars].[all cars].[ford] },
{ [measures].[sales_sum], [measures].[sales_n] } )
} ON COLUMNS,
NONEMPTY { [date].members } ON ROWS
FROM mddbcars