Exists Function - MDX Query

In MDX query is we want to find that particular set or tuples exists in the given second set ,we can use this function
If we provide optional measure group then it will also check the tuples has non NULL data in that measure group




Exists( Set_Expression1 , Set_Expression2 [, MeasureGroupName] )

Examples

Here in this example if the year value is between 2003 to 2004 we want to show Inside else we want to show Outside.
So we have to check that every year value is between 2003 and 2004 or not.

with member [Measures].[test]
as
iif(isempty((exists ([Date].[Fiscal].currentmember,{[Date].[Fiscal].
[Fiscal Year].&[2003]:[Date].[Fiscal].[Fiscal Year].&[2004]}).item(0),
[Measures].[Internet Sales Amount])),"Outside","inside")

select {[Measures].[Internet Sales Amount], [Measures].[test]} on 0 ,
[Date].[Fiscal].[Fiscal Year] on 1
from
[Adventure Works]


1 comment:

Unknown said...

That's great, Amish, but... the formatting of the code (and even the text) on the page is atrocious. Could you please make it more pleasant to the eye? You are certainly good at what you do, I have no doubts about it, but because of things like this you lose a lot in terms of professionalism and people don't view your work with the respect it certainly deserves. Secondly, the title: "Hi I am working with SQL Server Database and BI (SSAS, SSRS,SSIS) since last 8 years with some of worlds large databases." should have read more or less this way: "Hi, I HAVE BEEN working with SQL Server databases and the BI Stack (SSAS, SSRS, SSIS) FOR THE last 8 years including some of world's largest databases." Essentially, what I'm trying to say is that your English is a bit on the wanting side... Please don't take it amiss. I'm trying to help you, not to play you down. If I may, I'd strongly suggest you learn when to use the Present Perfect/Present Continuous tense and what the difference is in meaning between 'since' and 'for'. Best regards, Darek.

Post a Comment

Popular Posts