Quantcast
Channel: SQL Server Analysis Services forum
Viewing all articles
Browse latest Browse all 14337

Excel Pivot generating incorrect MDX results

$
0
0

Hi,

Using excel 2010 to connect to SSAS 2008R2 cube. What i have tried to do in MDX is to create a calculated measure that will return the Max (and  min) value accross (selected) time for a measure called Diversified MVaR.  I struggled with this, and the below is what i came up with.

WITH MEMBER [Measures].[Maximum MVaR]
 AS 
MAX( EXCEPT(EXISTING [Dates].[Run Date].,[Dates].[Run Date].[ALL]) ,ABS(measures.[Diversified MVaR]))
,FORMAT_STRING = "#,##0;-#,##0" 

This works fine if i write a simple MDX query like:

WITH MEMBER [Measures].[Maximum MVaR2]
 AS 
MAX( EXCEPT(EXISTING[Dates].[Run Date].MEMBERS,[Dates].[Run Date].[ALL]) ,ABS(measures.[Diversified MVaR]))
select  ( [Portfolio].[Portfolio Name].&[2345460/STRATEGY:1023])  on rows,
{measures.[Diversified MVAR],[Measures].[Maximum MVaR]} on columns
from MVAR
where {[Dates].[Run Date].&[20130523],[Dates].[Run Date].&[20130524]}

This correctly produces the max/min for 2 dates in the where clause.

My first question is, is there an easier way to do this?  I dont want MAX across all dimensions, only by time.  A sort of MaxOfChildren function if you like.

The problem with this code is that when i put the measure into the calculation script of the cube and then query it with an Excel Pivot, the subtotal for the portfolio displays the maximum for ALL TIME and not for the time members actually selected/filtered.

Capturing the MDX from the pivot gives this:

SELECT {[Measures].[Diversified MVaR],[Measures].[Maximum MVaR],[Measures].[Minimum MVaR]} 
ON COLUMNS , 
NON EMPTY 
CrossJoin(Hierarchize(DrilldownMember({{DrilldownLevel(
{[Portfolio].[Portfolio Name].[All]},,,INCLUDE_CALC_MEMBERS)}}, 
{[Portfolio].[Portfolio Name].&[2345460/STRATEGY:1023]},,,INCLUDE_CALC_MEMBERS)), 
Hierarchize({DrilldownLevel({[Dates].[Run Date].[All]},,,INCLUDE_CALC_MEMBERS)})) 
DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME,
[Portfolio].[Portfolio Name].[Portfolio Name],
[Portfolio].[Portfolio Name].[Portfolio Origin],
[Portfolio].[Portfolio Name].[Portfolio_Region],
[Portfolio].[Portfolio Name].[Portfolio_Type],
[Dates].[Run Date].[Run Date].[Week] ON ROWS  
FROM (
SELECT (
{[Portfolio].[Portfolio Name].&[2345460/STRATEGY:1023]},
{[Dates].[Run Date].&[20130524], [Dates].[Run Date].&[20130523]}) ON COLUMNS  
FROM [MVaR]) 

Running this MDX against the cube in SSMS shows that the subtotals given in Excel are a result of this query returning values for the ALL member of the date dimension - ie the max across all dates, and the wrong answer.

Can anyone offer any help please?

Thanks


Guy


Viewing all articles
Browse latest Browse all 14337

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>