2

我希望这个结果在变化为负时显示为负,但看起来 mdx 正在采用绝对结果并且始终显示正数。当第三个成员的结果为负时,我想将它设为负的第三列:

member [Measures].[Change in Reseller Sales Percent]

我想我可以用 iif 声明来做到这一点,但如何做到这一点?

代码:

with
member [Measures].[Prev Month Reseller Sales Amount] as
    ([Date].[Calendar].currentmember.prevmember,
    [Measures].[Reseller Sales Amount])
    ,format_string="currency"

member [Measures].[Change in Reseller Sales] as
    ([Measures].[Reseller Sales Amount]-
    [Measures].[Prev Month Reseller Sales Amount])

member [Measures].[Change in Reseller Sales Percent] as
    iif([Date].[Calendar].currentmember.prevmember is null, null,
        ([Measures].[Change in Reseller Sales])/ 
    ([Measures].[Prev Month Reseller Sales Amount]))
    , format_string = "percent"
SELECT
 {([Measures].[Reseller Sales Amount]),
 ([Measures].[Prev Month Reseller Sales Amount]),
 ([Measures].[Change in Reseller Sales]),
 ([Measures].[Change in Reseller Sales Percent])} ON COLUMNS,
 {[Date].[Calendar].[Month].Members} ON ROWS
FROM [Step-by-Step]

结果:

September 2001  $1,165,897.08   $1,538,408.31   ($372,511.23)   -24.21%
October 2001    $844,721.00 $1,165,897.08   ($321,176.08)   -27.55%
November 2001   $2,324,135.80   $844,721.00 $1,479,414.80   175.14%
December 2001   $1,702,944.54   $2,324,135.80   ($621,191.25)   -26.73%
January 2002    $713,116.69 $1,702,944.54   ($989,827.85)   -58.12%
4

1 回答 1

1

您应该为 format_string 中的负数指定格式说明符。例子

    format_string "$#,##0;-$#,##0"
于 2013-03-19T20:49:41.853 回答