Reputation: 451
I'm working on a calculated measure in SQL Server Analysis Service. the case is as follows;
we have a string value that holds a 4 digit numeric value. if the value starts with 7 we want to add a value with another value, if not then we just want to display the value.
i tried to use a when statement first, with a then and an else portion;
Case
when (Left([Kostensoort].[Kosten code], 1) is "7")
Then [Measures].[Inkoop bedrag] + [Measures].[Bank bedrag]
Else [Measures].[Inkoop bedrag]
End
this doesn't seem to work.
i then changed it to an if statement like this;
if (Left([Kostensoort].[Kosten code], 1) is "7")
then [Measures].[Inkoop bedrag] + [Measures].[Bank bedrag]
else [Measures].[Inkoop bedrag]
end if
it keeps saying there is an error at the then keyword, which leads me to believe i did something wrong with the if statement
i also replaced the is with a '=' to see if that mattered, which it didn't
i found multiple sources on the internet saying what i can and can't do in a mdx expression;
http://msdn.microsoft.com/en-us/library/ms145517.aspx http://www.iccube.com/support/documentation/mdx/functions.html http://publib.boulder.ibm.com/infocenter/comphelp/v101v121/index.jsp?topic=/com.ibm.xlf121.aix.doc/proguide/ifclause.html http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/index.jsp?topic=%2Fcom.ibm.dwe.cubemdx.doc%2Fmdx_expressions.html
but none seem to solve my problem.
obvouisly im missing something, is there anyone there that has expercience with MDX and SSAS, that can give me a few pointers or a direction?
Upvotes: 2
Views: 11314
Reputation: 1
[Measures].[Your Measure] = [Measures].[Inkoop bedrag] + Iif(Left([Kostensoort].[Kosten code], 1) = "7", [Measures].[Bank bedrag], null)
Upvotes: 0
Reputation: 9375
In MDX you should use the IIF function; there's no IF / THEN / ELSE that I know of.
Upvotes: 3