简体   繁体   中英

Using “Show values as” option in Excel 2007 pivot table when source is SSAS cube?

I have an Excel 2007 pivot table showing "Year" across the top and "Month" down the side. What I am trying to do is represent the values as "% Difference" from the same month of the previous year. (Ex. If Jan-07 is $100,000 and Jan-08 is $120,000, I would like Jan-08 to show '20%'). However, every time I try to do this (using the "Show values as" tab of Value Field Settings) all of my numbers go to '#N/A'. Is there a way to do this using an Analysis Services cube as the data source? When I do this exact same thing using data on a different sheet as the data source for the pivot table, it works fine.

I'm not sure if there is any way of doing this in Excel, but you could create a calculated measure in your cube that would do it.

The MDX expression would look something like the following:

([Measures].[Amount] - ([Date].[Year].PrevMember, [Measures].[Amount])) 
/ ([Measures].[Amount])

Ref period to period comparisons, you could use the following calculation script. YearMonthDate is the hierarchy on the date dimension, but you could have quarter in there too for your requirement.

/* The CALCULATE command controls the aggregation of leaf cells in the cube. If the CALCULATE command is deleted or modified, the data within the cube is affected. You should edit this command only if you manually specify how the cube is aggregated. */

CALCULATE; 
CREATE MEMBER CURRENTCUBE.[MEASURES].PrevPeriod
 AS ([Measures].[Count],  [Date].[YearMonthDate].CURRENTMEMBER.PREVMEMBER ), 
FORMAT_STRING = "#,#", 
VISIBLE = 1  ; 

CREATE MEMBER CURRENTCUBE.[Measures].PeriodChange
 AS ([Measures].[Count] - [Measures].[PrevPeriod]), 
FORMAT_STRING = "#,#", 
VISIBLE = 1  ;     
CREATE MEMBER CURRENTCUBE.[Measures].PercentChange
 AS (
        [Measures].[PeriodChange]/
        IIF(    ([Measures].[PrevPeriod] = 0), 
                [Measures].[Count],
                [Measures].[PrevPeriod]
            )
    ), 
FORMAT_STRING = "Percent", 
VISIBLE = 1;     
CREATE MEMBER CURRENTCUBE.[Measures].YearToDate
 AS (
       SUM(PeriodsToDate([Date].[YearMonthDate].[Year Code]), [Measures].[Count])
    ), 
FORMAT_STRING = "#,#", 
VISIBLE = 1;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM