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

Implicit Aggregate in pivot table ?

$
0
0

I am using Excel to query an OLAP SSAS cube. Without any filter, the pivot table I have is: 

Values
SCM Lines Count94741
OTR_Net87.28%
OTD_Net

95.00%

I need to consolidate these metrics on the first complete months of the year. So I create a named set. The corresponding code in the MDX query that Excel generates is:

SET [YTD] as VisualTotals({[Delivery Date].[Period Hiearchy].[All],YTD(StrToMember("[Delivery Date].[Period Hiearchy].[Month].&"+
FORMAT(Now(),"[yyyyMM01]")+ ".PrevMember"))})

When I drag and drop this set to the columns area of the pivot table, I get this:

Values 2014-01 2014-02 Grand Total
SCM Lines Count371536087323
OTR_Net81.77%84.77%83.24%
OTD_Net91.66%94.33%92.97%

So far so good, but I would like to remove the months and only keep the Grand Total. But you cannot move a set to the page filter area, so I tried the following workaround with the add-in "OLAP Pivot table extensions": I remove the set from the columns area (the result changes back to the first table above), and add a calculated metric:

[Measures].[YTDCount] AS Aggregate([YTD],[Measures].[SCM Lines Count])

And - surprise -, I get the result below: The other metrics are also filtered on the [YTD] set, even though it is not explicitly set as a filter in the pivot table.

Values
SCM Lines Count7323
OTR_Net83.24%
OTD_Net92.97%
YTDCount14646

The final MDX query is:

WITH
SET [YTD] as VisualTotals({[Delivery Date].[Period Hiearchy].[All],YTD(StrToMember("[Delivery Date].[Period Hiearchy].[Month].&"+
FORMAT(Now(),"[yyyyMM01]")+ ".PrevMember"))})
MEMBER [Measures].[YTDCount] as AGGREGATE([YTD],[Measures].[SCM Lines Count])
SELECT {[Measures].[SCM Lines Count],[Measures].[OTR_Net],[Measures].[OTD_Net]} DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME ON COLUMNS  FROM [METRICS] CELL PROPERTIES VALUE, FORMAT_STRING, LANGUAGE, BACK_COLOR, FORE_COLOR, FONT_FLAGS

Even if I unselect my custom metric YTDCount (which gives twice the correct result btw), the result for the other metrics remains unchanged. The final pivot table is indeed what I wanted, but I do not want to use what seems a dirty hidden trick.

Can anyone explain why the custom metrics also impacts other measures ?

Would anyone have a proposal for a set definition that would generates either only one column or a hierarchy where I could hide the month level. ?
<object height="1" id="plugin0" style=";z-index:1000;" type="application/x-dgnria" width="1"><param name="tabId" value="{D6D21951-03EF-4DE5-AA00-FEF24C66552F}" /></object>


Viewing all articles
Browse latest Browse all 14337

Trending Articles



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