问题
I'm very new to MDX so I hope this is a simple question for a MDX expert. I have the following expression SUM(PeriodsToDate([Accounting Date].[(All)]),[Measures].[Amount]) which this piece works as expected. I need to add a filter or IIF statement that basically does the following:
IF
SUM(PeriodsToDate([Accounting Date].[(All)]),[Measures].[Amount]) < 0
Then 0
Else
SUM(PeriodsToDate([Accounting Date].[(All)]),[Measures].[Amount])
回答1:
I'm afraid it's impossible to do with pre-aggregated data. The MDX IIF function works per a member, the SQL IIF works per a row. You have to add a measure like Amount, but with iif([Amount] < 0,0,[Amount]). Also you may try the code below, nonetheless, I doubt it results properly:
SUM(
NULL:[Accounting Date].[Calendar].CurrentMember,
IIF(
[Measures].[Amount] < 0,
NULL,
[Measures].[Amount]
)
)
来源:https://stackoverflow.com/questions/42167709/mdx-and-periodstodate