A matrix can be build as a crossjoin of two sets. The numerical expression specified as parameter is applied to each tuple. The first set define the rows of the matrix, the second one the columns.
Query
WITH
MEMBER [Measures].[val] AS Matrix({[Time].[Calendar].[2010],[Time].[Calendar].[2011]}, {[Geography].[Geo].[Switzerland],[Geography].[Geo].[France]}, [Measures].[Amount] )
SELECT
[Measures].[val] ON 0
FROM
[Sales]
Result
val |
[[248.0, 0.0], [4.0, 0.0]] |
Assertion : Cell Equals
WITH
MEMBER [col1] AS VectorN( ([Geography].[Geo].[Switzerland],[Time].[Calendar].[2010],[Amount]), ([Geography].[Geo].[France],[Time].[Calendar].[2010],[Amount]) )
MEMBER [col2] AS VectorN( ([Geography].[Geo].[Switzerland],[Time].[Calendar].[2011],[Amount]), ([Geography].[Geo].[France],[Time].[Calendar].[2011],[Amount]) )
MEMBER [Measures].[val] AS MatrixN( [col1].value(), [col2].value() )
SELECT
[Measures].[val] ON 0
FROM
[Sales]
An example of matrix inversion.
Query
WITH
MEMBER [Measures].[matrix-a] AS MatrixA( nonempty([Geography].[Geo].[Country],[Measures].[Amount]).tail(4), [Product].[Prod].[Licence].head(4), [Measures].[Amount] + 2.0 )->inverse()
SELECT
[Measures].[matrix-a] on Axes
FROM
[Sales]
Result
|
Corporate |
Partnership |
Personal |
Startup |
United States |
0.0013020833333333335 |
-0.001953125 |
5.767392335715099E-19 |
6.510416666666651E-4 |
France |
0.003906250000000002 |
-0.05794270833333328 |
1.0000000000000002 |
-2.4459635416666674 |
Spain |
-0.005208333333333336 |
0.0494791666666666 |
-1.0000000000000004 |
2.955729166666668 |
Switzerland |
-0.0 |
0.010416666666666666 |
-0.0 |
-0.010416666666666666 |
An example to show we're actually calculating the matrix inverse.
Query
WITH
MEMBER [Measures].[matrix-a] AS Matrix( nonempty([Geography].[Geo].[Country],[Measures].[Amount]).tail(4), [Product].[Prod].[Licence].head(4), [Measures].[Amount] + 2.0 )
MEMBER [Measures].[matrix-i] AS ([matrix-a]->inverse() * [matrix-a])->round(10)
SELECT
[Measures].[matrix-i] on 0
FROM
[Sales]
Result
matrix-i |
[[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]] |
Assertion : Cell Equals
WITH
MEMBER [Measures].[val] AS MatrixN( VectorN(1,0,0,0), VectorN(0,1,0,0), VectorN(0,0,1,0), VectorN(0,0,0,1) )
SELECT
[Measures].[val] ON 0
FROM
[Sales]