Hello,
I have a MDX query with two dimensions (KBC Account and Badge).
What I want to accomplish is:
- KBC account must not be 834 or 322
or
- KBC account must not be 320 in combination with Badge BRA
So in SQL language this would be:
where kbc_account != 834 or kbc_account != 322 or !(kbc_account = 320 and badge = 'bra')
How can I achive this with MDX?
I have tried something like this (subtext from the query) (but no result):
(
SELECT ( - {
[Symbol].[Dim KBC Account].[KBC Account Number].[834],
[Symbol].[Dim KBC Account].[KBC Account Number].[320]
} ) ON 0 FROM
[CUBE]
)
WHERE
( IIF ( [Symbol].[Dim KBC Account].[KBC Account Number].[322], (-{[Badge].[Dim Badge].[Badge].[BRA]}), 0 ) )
Regards
Hessel Appers
Could you give some examples with data, because there seem to be some logical discrepancies in the SQL where clause above:
"where kbc_account != 834 or kbc_account != 322" will always be true, since it can't be both.
Assuming the above should be: "where kbc_account != 834 and kbc_account != 322" - if this is false, then kbc_account is either 834 or 322. In that case, "or !(kbc_account = 320 and badge = 'bra')" will always be true, since kbc_account can't be 320.
|||
I will try your MDX query.
Sorry for the incorrect SQL. This must be:
WHERE (kbc_account_number <> 834) AND (kbc_account_number <> 320) AND NOT (kbc_account_number = 322 AND badge = 'BRA')
Now the SQL is correct will your MDX interpretation still be the same?
|||It should be the same, except for a typo which I've corrected below:
Code Snippet
where
Except(CrossJoin([Symbol].[Dim KBC Account].[KBC Account Number], [Badge].[Dim Badge].[Badge]),
{CrossJoin({[Symbol].[Dim KBC Account].[KBC Account Number].[834]}, [Badge].[Dim Badge].[Badge]),
CrossJoin({[Symbol].[Dim KBC Account].[KBC Account Number].[320]}, [Badge].[Dim Badge].[Badge]),
([Symbol].[Dim KBC Account].[KBC Account Number].[322], [Badge].[Dim Badge].[Badge].[BRA])})
|||Thnx Deepak,
I changed the MDX with your code and it works fine.
Ticket closed!
No comments:
Post a Comment