我希望这个结果在变化为负时显示负数,但看起来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%
答案 0 :(得分:1)
您应该在format_string中指定负数的格式说明符。实施例
format_string "$#,##0;-$#,##0"