Showing posts with label mdx. Show all posts
Showing posts with label mdx. Show all posts

Thursday, February 16, 2012

About Members and Ordinal function

When I use MDX sample application,
I write a code like this:

SELECT

{[Time].[All Time].[2005]} ON COLUMNS,

{Filter([Equipment].Members, (InStr(1, [Equipment].CurrentMember.Name, "xxxx") =1))} ON ROWS

FROM francis.

Here Equipment is a huge dimension table,actually I want to do it like

Filter([Equipment].[All types].[mechanism].Members to narrow the range as prevent duplicate.
But it failed.

One more is I can't use ordinal function in it too, but I can do it in AS and test in pivottables.

Can someone tell me the reasons?
This is probably the same issue as I mentioned on the other thread - you probably need to use the .Children function instead of the .Members function. The .Children function returns all the members 'underneath' a member in a hierarchy, the .Members function returns all the members on a dimension or level. So:
[Equipment].[All types].[mechanism].Children
should work for you.

I'm not sure what you mean about your problem with the Ordinal function - can you provide more details?

Chris|||Hi, Chris, give you more details as example. I assume[Equipment].[All types].[mechanism].[machine001] have [abc],[bcd],[efg],[hij] these children like [Equipment].[All types].[mechanism].[machine001].[abc], and in them they all have a children call [ABSmain_xxxx] like [Equipment].[All types].[mechanism].[machine001].[abc].ABSmain_abc.
Now I want to average all the ABSmain_xxx value, so I will do a filter to the set I reach now.
If I use [Equipment].[All types].[mechanism].[machine001].Children, it will only filter the [abc],[bcd]...etc, it won't go deep to their children.
I suppose to do it like [Equipment].[All types].[mechanism].[machine001].[abc].level.members,I think it will work.

|||No, your last example won't do what you want, I think - it will return all the members on the same level as[Equipment].[All types].[mechanism].[machine001].[abc]. Does[Equipment].[All types].[mechanism].[machine001].[abc].CHILDREN do what you want? Otherwise, you might want to check out the DESCENDANTS function.

You might want to read some of the articles in the 'MDX Essentials' series here:
http://www.databasejournal.com/article.php/1459531/
Especially the ones on 'family' functions such as this one:
http://www.databasejournal.com/features/mssql/article.php/2168911

HTH,

Chris|||Hi, Chris, I have checked the descendants function and it is the one I want, it works fine expect for a little longer query time than I thought.

About Members and Ordinal function

When I use MDX sample application,
I write a code like this:

SELECT

{[Time].[All Time].[2005]} ON COLUMNS,

{Filter([Equipment].Members, (InStr(1, [Equipment].CurrentMember.Name, "xxxx") =1))} ON ROWS

FROM francis.

Here Equipment is a huge dimension table,actually I want to do it like

Filter([Equipment].[All types].[mechanism].Members to narrow the range as prevent duplicate.
But it failed.

One more is I can't use ordinal function in it too, but I can do it in AS and test in pivottables.

Can someone tell me the reasons?
This is probably the same issue as I mentioned on the other thread - you probably need to use the .Children function instead of the .Members function. The .Children function returns all the members 'underneath' a member in a hierarchy, the .Members function returns all the members on a dimension or level. So:
[Equipment].[All types].[mechanism].Children
should work for you.

I'm not sure what you mean about your problem with the Ordinal function - can you provide more details?

Chris|||Hi, Chris, give you more details as example. I assume [Equipment].[All types].[mechanism].[machine001] have [abc],[bcd],[efg],[hij] these children like [Equipment].[All types].[mechanism].[machine001].[abc], and in them they all have a children call [ABSmain_xxxx] like [Equipment].[All types].[mechanism].[machine001].[abc].ABSmain_abc.
Now I want to average all the ABSmain_xxx value, so I will do a filter to the set I reach now.
If I use [Equipment].[All types].[mechanism].[machine001].Children, it will only filter the [abc],[bcd]...etc, it won't go deep to their children.
I suppose to do it like [Equipment].[All types].[mechanism].[machine001].[abc].level.members,I think it will work.

|||No, your last example won't do what you want, I think - it will return all the members on the same level as [Equipment].[All types].[mechanism].[machine001].[abc]. Does [Equipment].[All types].[mechanism].[machine001].[abc].CHILDREN do what you want? Otherwise, you might want to check out the DESCENDANTS function.

You might want to read some of the articles in the 'MDX Essentials' series here:
http://www.databasejournal.com/article.php/1459531/
Especially the ones on 'family' functions such as this one:
http://www.databasejournal.com/features/mssql/article.php/2168911

HTH,

Chris|||Hi, Chris, I have checked the descendants function and it is the one I want, it works fine expect for a little longer query time than I thought.

Thursday, February 9, 2012

About Count(Distinct) in AS

Hi,
Could Cube or MDX in Analysis Services execute "Count(Distinct)" or
"Sum(IIF())" Syntax?
If it could be, how could I open or write Count(Distinct) or Sum(IIF())
function or syntax in Cube?
As we know, MDX could execute Sum(IIF()), and how about Count(Distinct)?
Thanks!You can add an MDX expression in the cube definition, then the results of
the expression will be available as a cube cell, without re building the
cube...THis can be done in the cube editor of AS.
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"angi" <angi@.microsoft.com> wrote in message
news:uuY2g6nfEHA.2468@.TK2MSFTNGP12.phx.gbl...
> Hi,
> Could Cube or MDX in Analysis Services execute "Count(Distinct)" or
> "Sum(IIF())" Syntax?
> If it could be, how could I open or write Count(Distinct) or Sum(IIF())
> function or syntax in Cube?
> As we know, MDX could execute Sum(IIF()), and how about Count(Distinct)?
> Thanks!
>

About Count(Distinct) in AS

Hi,
Could Cube or MDX in Analysis Services execute "Count(Distinct)" or
"Sum(IIF())" Syntax?
If it could be, how could I open or write Count(Distinct) or Sum(IIF())
function or syntax in Cube?
As we know, MDX could execute Sum(IIF()), and how about Count(Distinct)?
Thanks!
You can add an MDX expression in the cube definition, then the results of
the expression will be available as a cube cell, without re building the
cube...THis can be done in the cube editor of AS.
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"angi" <angi@.microsoft.com> wrote in message
news:uuY2g6nfEHA.2468@.TK2MSFTNGP12.phx.gbl...
> Hi,
> Could Cube or MDX in Analysis Services execute "Count(Distinct)" or
> "Sum(IIF())" Syntax?
> If it could be, how could I open or write Count(Distinct) or Sum(IIF())
> function or syntax in Cube?
> As we know, MDX could execute Sum(IIF()), and how about Count(Distinct)?
> Thanks!
>

About Count(Distinct) in AS

Hi,
Could Cube or MDX in Analysis Services execute "Count(Distinct)" or
"Sum(IIF())" Syntax?
If it could be, how could I open or write Count(Distinct) or Sum(IIF())
function or syntax in Cube?
As we know, MDX could execute Sum(IIF()), and how about Count(Distinct)?
Thanks!You can add an MDX expression in the cube definition, then the results of
the expression will be available as a cube cell, without re building the
cube...THis can be done in the cube editor of AS.
--
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"angi" <angi@.microsoft.com> wrote in message
news:uuY2g6nfEHA.2468@.TK2MSFTNGP12.phx.gbl...
> Hi,
> Could Cube or MDX in Analysis Services execute "Count(Distinct)" or
> "Sum(IIF())" Syntax?
> If it could be, how could I open or write Count(Distinct) or Sum(IIF())
> function or syntax in Cube?
> As we know, MDX could execute Sum(IIF()), and how about Count(Distinct)?
> Thanks!
>