Showing posts with label cube. Show all posts
Showing posts with label cube. Show all posts

Thursday, March 22, 2012

DISTINCT COUNT WITH NULL VALUES (GRAND TOTAL)

Hello,

I have a DB of professors and information related with them. I created the cube, it consist of:

Measures:

Measure group Professors:

Amount of projects (COUNT proj_id)

Amount of pulications (COUNT pub_id)

Amount of e_books (COUNT book_id)

--

Measure group Projects:

Distinct amount of projects (DISTINCT COUNT proj_id)

--

Measure group Publications:

Distinct amount of publications (DISTINCT COUNT pub_id)

--

Measure group E_books:

Distinct amount of e_books (DISTINCT COUNT book_id)

Calculated measures:

Amnt_Projects

iif ([Measures].[ Amount of projects ] = 0 OR [Measures].[ Amount of projects] = NULL,0,[Measures].[ Distinct amount of projects])

Amnt_Publications

(similar to the above one)

Amnt_E_books

(similar to the above one)

Dimensions:

dimPROFESSORS

- prof_id

-surname

-name

-gender

dimPROJECTS

- proj_id

-type name

-name

dimPUBLICATIONS

- pub_id

-type name

-name

dimE_BOOKS

- book_id

-name

Data_Projects

-data_id

-years

Data_Publications

-data_id

-years

Data_E_books

-data_id

-years

For example, when I browse the cube:

prof_id Amount of projects Distinct amount of projects Amnt_Projects

1032 30 1 1

1070 90 2 2

1111 0 1 0

1137 0 1 0

1234 1404 9 9

1721 504 7 7

2661 85 5 5

... ... ... ...

6999 20 1 1

9956 50 5 5

Uknown 0

Grand Total 2421 11 11

Grand Total “11“ is the amount of distinct projects +1 (because of the unknown member). So the last column shows the right amount of projects for the professor but I want Grand Total to sum those values and show, how many projects do the professors have (it should be ?59“ for all professors). How could I get the right value to be shown in Grand Total?

Any help would be appreciated as I'm very new to the MDX.

|||

Maybe you need to sum the project counts for each professor in the selection, like:

Amnt_Projects

Sum(existing [DimProfessors].[prof_id].[prof_id], [Measures].[ Distinct amount of projects])

|||Thank You Deepak. This calculation works perfectly, just i added my calculated measure expression instead of [Measures].[ Distinct amount of projects]. I am very happy that at last it works!!!
|||Hello again. I was working with KPI's and noticed, that this calculation needs to be improved. When I try to filter by any particular professor, the Grand Total remains the same - for the projects always "59". How could I change the calculateted member?

Thank You in advance.
|||

Were you testing the KPI with the KPI Browser in BIDS? If so, please check directly with an MDX query, since the browser may be using a subselect vs. where. The query would be like:

select

KPIValue("ProfCalc") on 0

from ProfCube

where [DimProfessors].[prof_id].&No

|||I tested Your SQL query, and You are right. This query works fine. But how can I make the KPI browser in BIDS show the right values (I use the Amnt_Projects calculation for the KPIValue expression)? The same with cube browser:

prof_id Amnt_Projects
1032 1
1070 2
1111 0
Grand Total 59

Thank You again. I appreciate Your help very much!
|||

In that case, a different approach may be needed, based on a recent Forum post:

- Create a new "row count" measure called Amnt_Projects for the Professors measure group.

- Add a statement to the cube MDX script, assigning values at the DimProfessors leaf level to Amnt_Projects:

([DimProfessors].[prof_id].[prof_id], [Measures].[Amnt_Projects]) = [Measures].[ Distinct amount of projects];

|||I don't know if I'm doing something wrong, but in this case I get #VALUE! for every professor.
First, I created a row count measure Amnt_Projects in the Professors measure group. Than I created calculated measure as You wrote and named it Amnt_projects2.

What is more, I am creating reports using this cube. I tried to make the one similar to the "Teritory Sales Drilldown" example. But the strange thing is with Amnt_Projects (the calculation, that You provided earlier). I make this kind of drilldown: Professor (Name/Surname) and Amnt_Publications->Type of Publication and Amnt_Publications->Name of Publication and Amnt_Publications

I get the results:
Professor Type of Publication Name of Publication Amnt_Publication
Professor1 #Error
Type1 0
Name1 0
Name2 0
Type2 #Error
Name3 1
Name4 0

So when the value of Amnt_Publication is 0, everything is ok, but when it has to sum one's, it shows #Error.

Thank You!
|||By the way, I get this cind of warning in the reporting services when I preview the report:
"The Value expression for the textbox ‘Amnt_Publications’ uses an aggregate function on data of varying data types. Aggregate functions other than First, Last, Previous, Count, and CountDistinct can only aggregate data of a single data type."
|||I have just notices that using distinct count fits me very well in this reporting services situation. It behaves very differently than in Analysis Services browser. In Reporting Services it counts distinct values and shows null value for those professors that have no publications. And in Analysis Services it shows "1" for null value. Indeed strange.

Still would appreciate Your help with those Amnt in Analysis Services, which I use for KPI value and browse in KPI browser.

Thank You!
|||"I created calculated measure as You wrote and named it Amnt_projects2" - in the approach which I suggested, there is no calculated measure. The cube script assignment applies to the new cube measure: "Amnt_Projects".|||Thank You for answering. But could You be more specific? (about "The cube script assignment applies to the new cube measure: "Amnt_Projects". ")This is my first try with SQL Server and I have only a couple of days to finish this.

What is more, I need those KPI using not the whole Amount of projects, but something like this:

KPI for projects = Amount of Type1 projects*0,6 + Amount of Type2projects *0,3 + Amount of Type3*0,1

as I mentioned, I have such kind of dimension Projects:

dimPROJECTS

- proj_id

-type name (there are three Types of projects)

-name (the name of project itself)


Thank You very much!
|||OK, I have just assigned the KPI value by myself and it works.Of course it works only in MS SQL Server Manegement Studio..I tested it by SQL query and it should work in Reporting Services. But because I'm still using that previous Amnt_projects -->Sum(existing [DimProfessors].[prof_id].[prof_id], [Measures].[ Distinct amount of projects]), it doesn't work properly in KPI browser. The KPI Value expresion is:

SUM([Dim Projects].[Type Name].&[Type1],[Measures].[Amnt_Projects])* 0.6 + SUM([Dim Projects].[Type Name].&[Type2],[Measures].[Amnt_Projects])* 0.3 + SUM([Dim Projects].[Type Name].&[Type3],[Measures].[Amnt_Projects]) * 0.1

So I would appreciate Your explanation about "The cube script assignment applies to the new cube measure: "Amnt_Projects". "

Thank You in advance!
|||

Not sure whether you reviewed the earlier post, which I provided a link to - but the approach I suggested is similar:

- Create a new "row count" measure called Amnt_Projects for the Professors measure group (this replaces the calculated measure: Amnt_Projects)

- Add this statement to the cube MDX script, assigning values at the DimProfessors leaf level to Amnt_Projects (it doesn't create any new measures):

([DimProfessors].[prof_id].[prof_id], [Measures].[Amnt_Projects]) = [Measures].[ Distinct amount of projects];

Distinct Count With Null Values (grand Total)

Hello,

I am using SQL Server 2005. I have a DB of professors and information related with them. I created the cube, it consist of:
Measures:
Measure group Professors:
Amount of projects (COUNT proj_id)
Amount of publications (COUNT pub_id)
Amount of e_books (COUNT book_id)
-----
Measure group Projects:
Distinct amount of projects (DISTINCT COUNT proj_id)
-----
Measure group Publications:
Distinct amount of publications (DISTINCT COUNT pub_id)
-----
Measure group E_books:
Distinct amount of e_books (DISTINCT COUNT book_id)
Calculated measures:
Amnt_Projects
iif ([Measures].[ Amount of projects ] = 0 OR [Measures].[ Amount of projects] = NULL,0,[Measures].[ Distinct amount of projects])
Amnt_Publications
(similar to the above one)
Amnt_E_books
(similar to the above one)
--------
Dimensions:
dimPROFESSORS
- prof_id
-surname
-name
-gender
dimPROJECTS
- proj_id
-type name
-name
dimPUBLICATIONS
- pub_id
-type name
-name
dimE_BOOKS
- book_id
-name
Date_Projects
-date_id
-years
Date_Publications
-date_id
-years
Date_E_books
-date_id
-years

For example, when I browse the cube:
prof_id____Amount of projects___Distinct amount of projects___Amnt_Projects
1032------ 30 --------1------1
1070------ 90 --------2------2
1111------ 0 --------1------0
1137------ 0 --------1------0
1234------1404--------9------9
1721------ 504--------7------7
2661------ 85 --------5------5
...------- ...--------...------...
6999------ 20--------1------1
9956------ 50--------5------5
Unknown------(empty)-------(empty)----0
Grand Total---- 2421--------11------11

Grand Total 11 is the amount of distinct projects +1 (because of the unknown member). So the last column shows the right amount of projects for the professor but I want Grand Total to sum those values and show, how many projects do the professors have (it should be 59 if for all professors). How could I get the right value to be shown in Grand Total?Any suggestions?|||if you want to include nulls in a count in t-sql, you can do something like this:

select count(distinct coalesce(mycolumn, 'THIS COLUMN IS NULL')) from mytable

DISTINCT COUNT WITH NULL VALUES (GRAND TOTAL)

Hello,

I have a DB of professors and information related with them. I created the cube, it consist of:

Measures:

Measure group Professors:

Amount of projects (COUNT proj_id)

Amount of pulications (COUNT pub_id)

Amount of e_books (COUNT book_id)

--

Measure group Projects:

Distinct amount of projects (DISTINCT COUNT proj_id)

--

Measure group Publications:

Distinct amount of publications (DISTINCT COUNT pub_id)

--

Measure group E_books:

Distinct amount of e_books (DISTINCT COUNT book_id)

Calculated measures:

Amnt_Projects

iif ([Measures].[ Amount of projects ] = 0 OR [Measures].[ Amount of projects] = NULL,0,[Measures].[ Distinct amount of projects])

Amnt_Publications

(similar to the above one)

Amnt_E_books

(similar to the above one)

Dimensions:

dimPROFESSORS

- prof_id

-surname

-name

-gender

dimPROJECTS

- proj_id

-type name

-name

dimPUBLICATIONS

- pub_id

-type name

-name

dimE_BOOKS

- book_id

-name

Data_Projects

-data_id

-years

Data_Publications

-data_id

-years

Data_E_books

-data_id

-years

For example, when I browse the cube:

prof_id Amount of projects Distinct amount of projects Amnt_Projects

1032 30 1 1

1070 90 2 2

1111 0 1 0

1137 0 1 0

1234 1404 9 9

1721 504 7 7

2661 85 5 5

... ... ... ...

6999 20 1 1

9956 50 5 5

Uknown 0

Grand Total 2421 11 11

Grand Total “11“ is the amount of distinct projects +1 (because of the unknown member). So the last column shows the right amount of projects for the professor but I want Grand Total to sum those values and show, how many projects do the professors have (it should be ?59“ for all professors). How could I get the right value to be shown in Grand Total?

Any help would be appreciated as I'm very new to the MDX.

|||

Maybe you need to sum the project counts for each professor in the selection, like:

Amnt_Projects

Sum(existing [DimProfessors].[prof_id].[prof_id], [Measures].[ Distinct amount of projects])

|||Thank You Deepak. This calculation works perfectly, just i added my calculated measure expression instead of [Measures].[ Distinct amount of projects]. I am very happy that at last it works!!!
|||Hello again. I was working with KPI's and noticed, that this calculation needs to be improved. When I try to filter by any particular professor, the Grand Total remains the same - for the projects always "59". How could I change the calculateted member?

Thank You in advance.
|||

Were you testing the KPI with the KPI Browser in BIDS? If so, please check directly with an MDX query, since the browser may be using a subselect vs. where. The query would be like:

select

KPIValue("ProfCalc") on 0

from ProfCube

where [DimProfessors].[prof_id].&No

|||I tested Your SQL query, and You are right. This query works fine. But how can I make the KPI browser in BIDS show the right values (I use the Amnt_Projects calculation for the KPIValue expression)? The same with cube browser:

prof_id Amnt_Projects
1032 1
1070 2
1111 0
Grand Total 59

Thank You again. I appreciate Your help very much!
|||

In that case, a different approach may be needed, based on a recent Forum post:

- Create a new "row count" measure called Amnt_Projects for the Professors measure group.

- Add a statement to the cube MDX script, assigning values at the DimProfessors leaf level to Amnt_Projects:

([DimProfessors].[prof_id].[prof_id], [Measures].[Amnt_Projects]) = [Measures].[ Distinct amount of projects];

|||I don't know if I'm doing something wrong, but in this case I get #VALUE! for every professor.
First, I created a row count measure Amnt_Projects in the Professors measure group. Than I created calculated measure as You wrote and named it Amnt_projects2.

What is more, I am creating reports using this cube. I tried to make the one similar to the "Teritory Sales Drilldown" example. But the strange thing is with Amnt_Projects (the calculation, that You provided earlier). I make this kind of drilldown: Professor (Name/Surname) and Amnt_Publications->Type of Publication and Amnt_Publications->Name of Publication and Amnt_Publications

I get the results:
Professor Type of Publication Name of Publication Amnt_Publication
Professor1 #Error
Type1 0
Name1 0
Name2 0
Type2 #Error
Name3 1
Name4 0

So when the value of Amnt_Publication is 0, everything is ok, but when it has to sum one's, it shows #Error.

Thank You!
|||By the way, I get this cind of warning in the reporting services when I preview the report:
"The Value expression for the textbox ‘Amnt_Publications’ uses an aggregate function on data of varying data types. Aggregate functions other than First, Last, Previous, Count, and CountDistinct can only aggregate data of a single data type."
|||I have just notices that using distinct count fits me very well in this reporting services situation. It behaves very differently than in Analysis Services browser. In Reporting Services it counts distinct values and shows null value for those professors that have no publications. And in Analysis Services it shows "1" for null value. Indeed strange.

Still would appreciate Your help with those Amnt in Analysis Services, which I use for KPI value and browse in KPI browser.

Thank You!
|||"I created calculated measure as You wrote and named it Amnt_projects2" - in the approach which I suggested, there is no calculated measure. The cube script assignment applies to the new cube measure: "Amnt_Projects".|||Thank You for answering. But could You be more specific? (about "The cube script assignment applies to the new cube measure: "Amnt_Projects". ")This is my first try with SQL Server and I have only a couple of days to finish this.

What is more, I need those KPI using not the whole Amount of projects, but something like this:

KPI for projects = Amount of Type1 projects*0,6 + Amount of Type2projects *0,3 + Amount of Type3*0,1

as I mentioned, I have such kind of dimension Projects:

dimPROJECTS

- proj_id

-type name (there are three Types of projects)

-name (the name of project itself)


Thank You very much!
|||OK, I have just assigned the KPI value by myself and it works.Of course it works only in MS SQL Server Manegement Studio..I tested it by SQL query and it should work in Reporting Services. But because I'm still using that previous Amnt_projects -->Sum(existing [DimProfessors].[prof_id].[prof_id], [Measures].[ Distinct amount of projects]), it doesn't work properly in KPI browser. The KPI Value expresion is:

SUM([Dim Projects].[Type Name].&[Type1],[Measures].[Amnt_Projects])* 0.6 + SUM([Dim Projects].[Type Name].&[Type2],[Measures].[Amnt_Projects])* 0.3 + SUM([Dim Projects].[Type Name].&[Type3],[Measures].[Amnt_Projects]) * 0.1

So I would appreciate Your explanation about "The cube script assignment applies to the new cube measure: "Amnt_Projects". "

Thank You in advance!
|||

Not sure whether you reviewed the earlier post, which I provided a link to - but the approach I suggested is similar:

- Create a new "row count" measure called Amnt_Projects for the Professors measure group (this replaces the calculated measure: Amnt_Projects)

- Add this statement to the cube MDX script, assigning values at the DimProfessors leaf level to Amnt_Projects (it doesn't create any new measures):

([DimProfessors].[prof_id].[prof_id], [Measures].[Amnt_Projects]) = [Measures].[ Distinct amount of projects];

sql

Distinct Count on non-numeric column AS 2000

I have a cube with a fact table containing figures as movements within months, therefore duplicating the associated references.

I need to be able to count the distinct references (text column), but in AS 2000 I cannot get a correct answer.

If I do a distinctcount on the Members of the dimension I get a lower count than there actually is.

I have tried placing the distinct references in a separate table joined to the fact table on the reference and then counting them, but that just gives me the total figure all the time. If I use distinctcount I get the same answer as using distinct count on the dimension, i.e. wrong!

This is very frustrating - does anyone have any ideas?

I know it would be fine in As2005 but we cannot upgrade just yet.

Thank you

Try to create a table in SQL with an identity column for each reference.

Change the way the fact tavle is loaded to the cube (may be using a view) and do the DistinctCount over the newly created column.

Hope it helps.

|||

Thanks for your suggestion.

I already have a table containing all the distinct references, which I build from the fact table (which is a proper table, not a view - I have encountered problems with counts when using views before!) link to the fact table by the reference and then create a hidden dimension with one level, the reference; it is the DistinctCount of these members which is coming out wrong, although when you look at the count of the dimension level it is correct.

Therefore I added an id column to this table and a corresponding level to the dimension and tried a DistinctCount of the Descendants of the dimension at the id level, but am still getting the incorrect count. I have looked at examples of the individual references that it is failing to count but cannot see any reason why.

|||

One question: are you doing the DistinctCount in the relational or in the OLAP?

If you do the DistinctCount in the relational and then feed it to the OLAP you must be aware that the sum of DistinctCounts is different from DistincCount of the sum.

I use views 99.9% of the time without problems.

My suggestion is to create a view for the facts to be able to return the id, the other metrics columns and all dimenstion columns. Then in the cube create the DistinctCount measure over the id column.

|||

I am now completely baffled by AS's inability to do a count.

As recommended I have added a numeric id column to the fact table relating to the reference I need to count, populated it, then created another cube as a copy of my original one but with only 1 measure, the DistinctCount of the ID column.

Even before I merge these 2 cubes into a virtual cube I can see that the count is STILL wrong - it shows in AS as 25538 whereas checking via SQL (i.e. select count(distinct ID) from FactCube) gives the correct answer of 25995.

This was the same incorrect number I was getting before when I tried a calculated member - where have the other 457 rows gone? I know of no other way to do this and really need some advice as to why AS appears unable to do a proper count. It is vital to the cube that this functionality is available.

We use Sybase as our relational database, in case this has any bearing on the matter.

Thank you

Rachel

|||

Hi,

I use Sybase IQ and little Sybase ASE as the source without problems. I think I had a problem with group by in IQ 12.6. However, it should not be relevant here.

Make sure the Relational query and OLAP query are comparable. Are you sure you do not have any other fact data, besides that query?

Get the select that AS2000 send to Sybase and analyze it. Then run it to compare the data.

DistinctCount is a very slow process, but in my experience accurate.

|||Thank you for that advice - I went through the SQL statement and eventually tracked down the problem to some dodgy data in one of the dimensions. Thank goodness for that!

Distinct Count Measures Spanning Partitions

We have a large cube partitioned now by week, whereas before it was one big
dumb partition. The problem is I don't know how to get DISTINCT COUNT
measures to behave properly. If I create a named set and do a SUM or an
AGGREGATE function of all the partitions in that set, it literally adds the
distinct counts from the partitions instead of doing a distinct count for al
l
the partitions in the set.
Is this even possible?Pl. note that, in AS 2000, Aggregate() will not work on Distinct Count
measures, whether the cube is partitioned or not. So it's not clear why
partitioning the cube would worsen problems with distinct count measures
- can you give a specific example of what happened?
http://groups-beta.google.com/group...erver.olap/msg/
5b7f7bedfe8d147e[vbcol=seagreen]
Newsgroups: microsoft.public.sqlserver.olap
From: "Sean Boon [MS]"
Date: Thu, 9 Oct 2003 13:02:57 -0700
Subject: Re: Distinct Count
Hi Chet,
Distinct count will work with MDX's WHERE clause. What doesn't work is
attempting to aggregate across sets that consist of multiple members.
In
other words you can't use the AGGREGATE() function or a calculated
member
based on the AGGREGATE() function in the where clause. It's a
limitation of
the distinct count aggregate type. There is a way around this though and
it's outlined in the following whitepaper.
http://msdn.microsoft.com/libr_ary/...ry/e_n-us/dnol.
.
Sean
Sean Boon
SQL Server BI Product Unit[vbcol=seagreen]
- Deepak
Deepak Puri
Microsoft MVP - SQL Server
*** Sent via Developersdex http://www.codecomments.com ***
Don't just participate in USENET...get rewarded for it!|||Sorry for not being more specific.
Calculated members based upon named sets that span what the cube is
partitioned by is what causes the problems.
Let's say there's a cube that is partitioned by month with this sample Fact
Data:
CustID TimeID
1 1
1 32
1 33
1 61
1 64
2 1
3 1
4 1
5 32
6 32
7 62
8 62
The TimeID's from 1-31 are Jan, 32-59 Feb, and 60+ are March, all of 1998.
I'm looking to get Distinct Count of Customers (CustID).
When querying the cube at the natural Year, Quarter, and Month levels, the
correct results are returned:
Year Distinct Count = 8
Quarter 1 Distinct Count = 8
Jan Distinct Count = 4
Feb Distinct Count = 3
Mar Distinct Count = 3
As you can see, drilling up and down with native members of dims in the cube
is just fine, regardless of partitioning.
However, we do a lot of dynamic rolling analysis. Various front ends will
generate a named set or calculated member, or both, for "the last N months."
Let's say I created a simple calculated member called "LastTwoMonths":
[Time].[1998 01] + [Time].[1998 02]
This returns 7, which is incorrect. It does the distinct count of each
partition and adds them together, which is not "correct" in the sense of tru
e
distinct counting. With the above data, the distinct count for those two
months should be 6.
I can't figure out how to get the distinct count to work properly when the
cube is partitioned by the same dimension that many calc members are based
upon.
Thanks for giving this matter the attention. I really appreciate it!
"Deepak Puri" wrote:

> Pl. note that, in AS 2000, Aggregate() will not work on Distinct Count
> measures, whether the cube is partitioned or not. So it's not clear why
> partitioning the cube would worsen problems with distinct count measures
> - can you give a specific example of what happened?
> http://groups-beta.google.com/group...erver.olap/msg/
> 5b7f7bedfe8d147e
> Newsgroups: microsoft.public.sqlserver.olap
> From: "Sean Boon [MS]"
> Date: Thu, 9 Oct 2003 13:02:57 -0700
> Subject: Re: Distinct Count
> Hi Chet,
> Distinct count will work with MDX's WHERE clause. What doesn't work is
> attempting to aggregate across sets that consist of multiple members.
> In
> other words you can't use the AGGREGATE() function or a calculated
> member
> based on the AGGREGATE() function in the where clause. It's a
> limitation of
> the distinct count aggregate type. There is a way around this though and
> it's outlined in the following whitepaper.
> http://msdn.microsoft.com/libr-ary/...ry/e-n-us/dnol.
> ..
> Sean
> --
> Sean Boon
> SQL Server BI Product Unit
>
> - Deepak
> Deepak Puri
> Microsoft MVP - SQL Server
> *** Sent via Developersdex http://www.codecomments.com ***
> Don't just participate in USENET...get rewarded for it!
>|||Based on your detailed description, I would re-iterate that, with AS
2000, you won't be able to roll up Distinct Count measures dynamically
in a calculated member. However, this should work in AS 2005 (Yukon), if
that's an option.
- Deepak
Deepak Puri
Microsoft MVP - SQL Server
*** Sent via Developersdex http://www.codecomments.com ***
Don't just participate in USENET...get rewarded for it!sql

Distinct count issue

Hello,
I have made a cube the following calculated member (with as parent member Measures):
COUNT(NONEMPTY( {[Parsed Logs Visitors].[Parsed Logs Visitors Dimension Table].[Parsed Logs Visitors Dimension Table]} *
{[Measures].[Parsed Logs Count]}))

Here I try to make a unique visitor count using the primary key in a non empty crossjoin with the fact table. When I query it with other dimension attributes it works fine, but it gives the total amount of unique visitors when I use (other) attributes of the same dimension.
How can I avoid that?

Thanks in advance,

Eyso Zanstra

You could try applying "existing" to the primary key attribute set:

COUNT(NONEMPTY( {Existing [Parsed Logs Visitors].[Parsed Logs Visitors Dimension Table].[Parsed Logs Visitors Dimension Table]} *
{[Measures].[Parsed Logs Count]}))

|||Yes, that did the trick.
Thank you!

Distinct Count in a new Measure Group

Here is the situation:

I have a cube that has transaction level data and there is a control number that goes with this data, but it isn't one for one. If I have 60 million rows in the fact table, I have 50 million control numbers in a control number dimension.

I would like to be able to slice the data by date (for instance) and then do a distinct count on the control number dimension. I can do a distinct count w.o having to do a join of course because I can count the distinct instances of the key to the control number dimension.

One more note - the control number dimension is not a degenerate dimension...it is not one to one on the fact table.

I would like to use the DISTINCT COUNT measure in SSAS, but it makes me create a new measure group to do so. All of my additive measures are in one group, the distinct count is forced into another group. This forces double the processing time.

Does anyone know why this behavour happens and can someone explain why a DISTINCT COUNT measure has to go in a seperate measure group?

Thanks,

Mark

Mark,

Do you already have a DISTINCT COUNT measure in that measure group? Analysis Services will only allow you to have one DISTINCT COUNT per measure group.

|||Maybe this MDX will overcome the limitation of one unqiue count.

Distinct(Filter([Customer].[Customer Name].Members,Not IsEmpty([Measures].[Sales Amount]))).Count

Timmy|||

Actually, I don't have one in the first measure group. The first measure group is just regular measures, but if I create a new measure that is a distinct count measure, it automatically puts it in another group.

I have now heard from other sources that this is an exptected behavior. So no biggie, just needed to know.

ps - sorry it took so long to respond.

Thanks,

Mark

http://spaces.msn.com/mgarnerbi

|||I noticed this too, does anyone know the underlying reason why this is? Is this going to be fixed in a future version?sql

Distinct Count in a new Measure Group

Here is the situation:

I have a cube that has transaction level data and there is a control number that goes with this data, but it isn't one for one. If I have 60 million rows in the fact table, I have 50 million control numbers in a control number dimension.

I would like to be able to slice the data by date (for instance) and then do a distinct count on the control number dimension. I can do a distinct count w.o having to do a join of course because I can count the distinct instances of the key to the control number dimension.

One more note - the control number dimension is not a degenerate dimension...it is not one to one on the fact table.

I would like to use the DISTINCT COUNT measure in SSAS, but it makes me create a new measure group to do so. All of my additive measures are in one group, the distinct count is forced into another group. This forces double the processing time.

Does anyone know why this behavour happens and can someone explain why a DISTINCT COUNT measure has to go in a seperate measure group?

Thanks,

Mark

Mark,

Do you already have a DISTINCT COUNT measure in that measure group? Analysis Services will only allow you to have one DISTINCT COUNT per measure group.

|||Maybe this MDX will overcome the limitation of one unqiue count.

Distinct(Filter([Customer].[Customer Name].Members,Not IsEmpty([Measures].[Sales Amount]))).Count

Timmy
|||

Actually, I don't have one in the first measure group. The first measure group is just regular measures, but if I create a new measure that is a distinct count measure, it automatically puts it in another group.

I have now heard from other sources that this is an exptected behavior. So no biggie, just needed to know.

ps - sorry it took so long to respond.

Thanks,

Mark

http://spaces.msn.com/mgarnerbi

|||I noticed this too, does anyone know the underlying reason why this is? Is this going to be fixed in a future version?

Distinct Count in a new Measure Group

Here is the situation:

I have a cube that has transaction level data and there is a control number that goes with this data, but it isn't one for one. If I have 60 million rows in the fact table, I have 50 million control numbers in a control number dimension.

I would like to be able to slice the data by date (for instance) and then do a distinct count on the control number dimension. I can do a distinct count w.o having to do a join of course because I can count the distinct instances of the key to the control number dimension.

One more note - the control number dimension is not a degenerate dimension...it is not one to one on the fact table.

I would like to use the DISTINCT COUNT measure in SSAS, but it makes me create a new measure group to do so. All of my additive measures are in one group, the distinct count is forced into another group. This forces double the processing time.

Does anyone know why this behavour happens and can someone explain why a DISTINCT COUNT measure has to go in a seperate measure group?

Thanks,

Mark

Mark,

Do you already have a DISTINCT COUNT measure in that measure group? Analysis Services will only allow you to have one DISTINCT COUNT per measure group.

|||Maybe this MDX will overcome the limitation of one unqiue count.

Distinct(Filter([Customer].[Customer Name].Members,Not IsEmpty([Measures].[Sales Amount]))).Count

Timmy
|||

Actually, I don't have one in the first measure group. The first measure group is just regular measures, but if I create a new measure that is a distinct count measure, it automatically puts it in another group.

I have now heard from other sources that this is an exptected behavior. So no biggie, just needed to know.

ps - sorry it took so long to respond.

Thanks,

Mark

http://spaces.msn.com/mgarnerbi

|||I noticed this too, does anyone know the underlying reason why this is? Is this going to be fixed in a future version?

Distinct Count Confusion

I have an issue with our cube. In the DW we have a column leadId. Performing a distinct count with no filters gives us about 18000 on that leadId. We have a measure using a Distinct Count on the leadId but the value only gives us about 15000 with no filters. Am I missing something with how the behavior of distinct count should act?Please, check queries that are issued from SSAS to the datasource database.|||

So I have found the reason the distinct values are being filtered, but I'm not sure what in our cube design is dictating the behavior to act this way. Here is the query issued to the DW... What confuses me is that planId is a nullable field. So I'm not sure why it would issue the statement like this. Any ideas?

SELECT [Facts_CurrentStatus].[Facts_CurrentStatusleadId0_0] AS [Facts_CurrentStatusleadId0_0],[Facts_CurrentStatus].[Facts_CurrentStatusapplicationId0_1] AS [Facts_CurrentStatusapplicationId0_1],[Facts_CurrentStatus].[Facts_CurrentStatusapplicationCustomerCount0_2] AS [Facts_CurrentStatusapplicationCustomerCount0_2],[Facts_CurrentStatus].[Facts_CurrentStatusapplicationPremium0_3] AS [Facts_CurrentStatusapplicationPremium0_3],[Facts_CurrentStatus].[Facts_CurrentStatuspolicyId0_4] AS [Facts_CurrentStatuspolicyId0_4],[Facts_CurrentStatus].[Facts_CurrentStatuspolicyCustomerCount0_5] AS [Facts_CurrentStatuspolicyCustomerCount0_5],[Facts_CurrentStatus].[Facts_CurrentStatuspolicyPremium0_6] AS [Facts_CurrentStatuspolicyPremium0_6],[Facts_CurrentStatus].[Facts_CurrentStatusleadArrivalToApplicationCompleteLagDays0_7] AS [Facts_CurrentStatusleadArrivalToApplicationCompleteLagDays0_7],[Facts_CurrentStatus].[Facts_CurrentStatusleadArrivalToPolicyIssueLagDays0_8] AS [Facts_CurrentStatusleadArrivalToPolicyIssueLagDays0_8],[Facts_CurrentStatus].[Facts_CurrentStatusapplicationCompleteToPolicyIssueLagDays0_9] AS [Facts_CurrentStatusapplicationCompleteToPolicyIssueLagDays0_9],[Facts_CurrentStatus].[Facts_CurrentStatusrateUp0_10] AS [Facts_CurrentStatusrateUp0_10],[Facts_CurrentStatus].[Facts_CurrentStatusapplicationOriginatedOnDate0_11] AS [Facts_CurrentStatusapplicationOriginatedOnDate0_11],[Facts_CurrentStatus].[Facts_CurrentStatussetByEmployeeId0_12] AS [Facts_CurrentStatussetByEmployeeId0_12],[Facts_CurrentStatus].[Facts_CurrentStatusutcDate0_13] AS [Facts_CurrentStatusutcDate0_13],[Facts_CurrentStatus].[Facts_CurrentStatuscarrierId0_14] AS [Facts_CurrentStatuscarrierId0_14],[Facts_CurrentStatus].[Facts_CurrentStatuspartnerId0_15] AS [Facts_CurrentStatuspartnerId0_15],[Facts_CurrentStatus].[Facts_CurrentStatusplanId0_16] AS [Facts_CurrentStatusplanId0_16],[Facts_CurrentStatus].[Facts_CurrentStatusleadOriginatedOnDate0_17] AS [Facts_CurrentStatusleadOriginatedOnDate0_17],[Facts_CurrentStatus].[Facts_CurrentStatuspolicyOriginatedOnDate0_18] AS [Facts_CurrentStatuspolicyOriginatedOnDate0_18],[Facts_CurrentStatus].[Facts_CurrentStatuspolicyIssuedOnDate0_19] AS [Facts_CurrentStatuspolicyIssuedOnDate0_19],[Facts_CurrentStatus].[Facts_CurrentStatuszipCodeId0_20] AS [Facts_CurrentStatuszipCodeId0_20],[Facts_CurrentStatus].[Facts_CurrentStatusapplicationCompletedOnDate0_21] AS [Facts_CurrentStatusapplicationCompletedOnDate0_21],[Facts_CurrentStatus].[Facts_CurrentStatusenrollerId0_22] AS [Facts_CurrentStatusenrollerId0_22],[Facts_CurrentStatus].[Facts_CurrentStatusagentId0_23] AS [Facts_CurrentStatusagentId0_23],[Facts_CurrentStatus].[Facts_CurrentStatuscustomerId0_24] AS [Facts_CurrentStatuscustomerId0_24],[Facts_CurrentStatus].[Facts_CurrentStatusstatusId0_25] AS [Facts_CurrentStatusstatusId0_25],[Facts_CurrentStatus].[Facts_CurrentStatuscampaignId0_26] AS [Facts_CurrentStatuscampaignId0_26],[Dimensions_Plan_20].[carrierId] AS [Dimensions_PlancarrierId3_0]

FROM

(

SELECT [leadId] AS [Facts_CurrentStatusleadId0_0],[applicationId] AS [Facts_CurrentStatusapplicationId0_1],[applicationCustomerCount] AS [Facts_CurrentStatusapplicationCustomerCount0_2],[applicationPremium] AS [Facts_CurrentStatusapplicationPremium0_3],[policyId] AS [Facts_CurrentStatuspolicyId0_4],[policyCustomerCount] AS [Facts_CurrentStatuspolicyCustomerCount0_5],[policyPremium] AS [Facts_CurrentStatuspolicyPremium0_6],DateDiff("d", leadOriginatedOnDate, applicationCompletedOnDate) AS [Facts_CurrentStatusleadArrivalToApplicationCompleteLagDays0_7],DateDiff("d", leadOriginatedOnDate, policyIssuedOnDate) AS [Facts_CurrentStatusleadArrivalToPolicyIssueLagDays0_8],DateDiff("d", applicationCompletedOnDate, policyIssuedOnDate) AS [Facts_CurrentStatusapplicationCompleteToPolicyIssueLagDays0_9],policyPremium - applicationPremium AS [Facts_CurrentStatusrateUp0_10],[applicationOriginatedOnDate] AS [Facts_CurrentStatusapplicationOriginatedOnDate0_11],[setByEmployeeId] AS [Facts_CurrentStatussetByEmployeeId0_12],[utcDate] AS [Facts_CurrentStatusutcDate0_13],[carrierId] AS [Facts_CurrentStatuscarrierId0_14],[partnerId] AS [Facts_CurrentStatuspartnerId0_15],[planId] AS [Facts_CurrentStatusplanId0_16],[leadOriginatedOnDate] AS [Facts_CurrentStatusleadOriginatedOnDate0_17],[policyOriginatedOnDate] AS [Facts_CurrentStatuspolicyOriginatedOnDate0_18],[policyIssuedOnDate] AS [Facts_CurrentStatuspolicyIssuedOnDate0_19],[zipCodeId] AS [Facts_CurrentStatuszipCodeId0_20],[applicationCompletedOnDate] AS [Facts_CurrentStatusapplicationCompletedOnDate0_21],[enrollerId] AS [Facts_CurrentStatusenrollerId0_22],[agentId] AS [Facts_CurrentStatusagentId0_23],[customerId] AS [Facts_CurrentStatuscustomerId0_24],[statusId] AS [Facts_CurrentStatusstatusId0_25],[campaignId] AS [Facts_CurrentStatuscampaignId0_26]

FROM [Facts].[CurrentStatus]

)

AS [Facts_CurrentStatus],[Dimensions].[Plan] AS [Dimensions_Plan_20]

WHERE

(

(

[Facts_CurrentStatus].[Facts_CurrentStatusplanId0_16] = [Dimensions_Plan_20].[surrogatePlanId] --Filters out the leads with no plan interest.

)

)

ORDER BY [Facts_CurrentStatus].[Facts_CurrentStatusleadId0_0]

ASC

|||

but I'm not sure what in our cube design is dictating the behavior to act this way.
Here is the query issued to the DW... What confuses me is that planId is a nullable field.

I don't know your cube design, therefore I can't say what is wrong.
My advice, try to avoid nullable field in the DW. It is not only my opinion.

|||Yes we already started to refactor the DW so the nullable fields would no longer exist. One thing though, I wasn't necessarily asking you to tell me how our design was wrong. I was more confused as to why AS would create a query that joins on a nullable field. Regardless, problem solved.

Sunday, March 11, 2012

Displaying Parent-Child OLAP data in a report in SQL2005 RS

I'm trying to use an OLAP cube as my data source (built using SSAS 2005)
The cube has a parent-child dimension and a fact table. I would like to
display the parent-child data in a report . Does anyone know how to build an
MDX query that would give me the ID and the ParentID from the dimension to
build the parent-child grouping relationship in the report? The MDX builder
does not let me access the ID field or the ParentID field. I always get the
Name of the dimension.
Also, if there's another way to do this, please let me know.
Any help is greatly appreciated.
ThanksI attached a sample report that shows how to do this.
Notes:
* in the graphical query designer you have to select a recursive hierarchy
from the cube (such as Employee.Employees in the AdventureWorks DW cube).
Based on the metadata, RS should automatically detect that this is a
recursive parent-child hierarchy and there will be additional extended field
properties available (such as .UniqueName and .ParentUniqueName)
* add a grouping in the report. The grouping expression is based on
=Fields!Employees.UniqueName and for the parent of the group set it to
=Fields!Employees.ParentUniqueName
* right now, you will need to have table columns that also reference the
UniqueName and the ParentUniqueName in the report - but you can hide them so
they are not visible. If you don't have these columns, the recursive
hierarchy won't work correctly.
-- Robert
This posting is provided "AS IS" with no warranties, and confers no rights.
"Raghu" <Raghu@.discussions.microsoft.com> wrote in message
news:A3B4E2B3-B78D-4571-9D90-69EC03FD18E4@.microsoft.com...
> I'm trying to use an OLAP cube as my data source (built using SSAS 2005)
> The cube has a parent-child dimension and a fact table. I would like to
> display the parent-child data in a report . Does anyone know how to build
> an
> MDX query that would give me the ID and the ParentID from the dimension to
> build the parent-child grouping relationship in the report? The MDX
> builder
> does not let me access the ID field or the ParentID field. I always get
> the
> Name of the dimension.
> Also, if there's another way to do this, please let me know.
> Any help is greatly appreciated.
> Thanks
==========================================================
<?xml version="1.0" encoding="utf-8"?>
<Report
xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition"
xmlns:rd="">http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
<DataSources>
<DataSource Name="DataSource1">
<ConnectionProperties>
<IntegratedSecurity>true</IntegratedSecurity>
<ConnectString>Data Source=(local);Initial Catalog="Adventure Works
DW"</ConnectString>
<DataProvider>OLEDB-MD</DataProvider>
</ConnectionProperties>
<rd:DataSourceID>5aaa5577-4975-4616-a136-0b713dab6948</rd:DataSourceID>
</DataSource>
</DataSources>
<BottomMargin>1in</BottomMargin>
<RightMargin>1in</RightMargin>
<rd:DrawGrid>true</rd:DrawGrid>
<InteractiveWidth>8.5in</InteractiveWidth>
<rd:SnapToGrid>true</rd:SnapToGrid>
<Body>
<ReportItems>
<Table Name="table1">
<Footer>
<TableRows>
<TableRow>
<TableCells>
<TableCell>
<ReportItems>
<Textbox Name="textbox7">
<rd:DefaultName>textbox7</rd:DefaultName>
<ZIndex>9</ZIndex>
<Style>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
</Style>
<CanGrow>true</CanGrow>
<Value />
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="textbox9">
<rd:DefaultName>textbox9</rd:DefaultName>
<ZIndex>8</ZIndex>
<Style>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
</Style>
<CanGrow>true</CanGrow>
<Value />
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="textbox8">
<rd:DefaultName>textbox8</rd:DefaultName>
<ZIndex>7</ZIndex>
<Style>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
</Style>
<CanGrow>true</CanGrow>
<Value />
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="textbox11">
<rd:DefaultName>textbox11</rd:DefaultName>
<ZIndex>6</ZIndex>
<Style>
<TextAlign>Center</TextAlign>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
</Style>
<CanGrow>true</CanGrow>
<Value />
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="textbox13">
<rd:DefaultName>textbox13</rd:DefaultName>
<ZIndex>5</ZIndex>
<Style>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
</Style>
<CanGrow>true</CanGrow>
<Value />
</Textbox>
</ReportItems>
</TableCell>
</TableCells>
<Height>0.25in</Height>
</TableRow>
</TableRows>
</Footer>
<DataSetName>DataSet1</DataSetName>
<Top>0.5in</Top>
<Details>
<TableRows>
<TableRow>
<TableCells>
<TableCell>
<ReportItems>
<Textbox Name="Employees">
<rd:DefaultName>Employees</rd:DefaultName>
<ZIndex>4</ZIndex>
<Style>
<PaddingLeft>=2 + Level() * 8 &
"pt"</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
</Style>
<CanGrow>true</CanGrow>
<Value>=Fields!Employees.Value</Value>
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="textbox10">
<ZIndex>3</ZIndex>
<Style>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
</Style>
<CanGrow>true</CanGrow>
<Value>=Fields!Employees.UniqueName</Value>
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="textbox5">
<rd:DefaultName>textbox5</rd:DefaultName>
<ZIndex>2</ZIndex>
<Style>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
</Style>
<CanGrow>true</CanGrow>
<Value>=Fields!Employees.ParentUniqueName</Value>
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="Reseller_Sales_Amount">
<rd:DefaultName>Reseller_Sales_Amount</rd:DefaultName>
<ZIndex>1</ZIndex>
<Style>
<TextAlign>Center</TextAlign>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
</Style>
<CanGrow>true</CanGrow>
<Value>=Level()</Value>
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="Reseller_Sales_Amount_1">
<rd:DefaultName>Reseller_Sales_Amount_1</rd:DefaultName>
<Style>
<TextAlign>Right</TextAlign>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
</Style>
<CanGrow>true</CanGrow>
<Value>=Sum(Fields!Reseller_Sales_Amount.Value)</Value>
</Textbox>
</ReportItems>
</TableCell>
</TableCells>
<Height>0.25in</Height>
</TableRow>
</TableRows>
<Grouping Name="table1_Details_Group">
<Parent>=Fields!Employees.ParentUniqueName</Parent>
<GroupExpressions>
<GroupExpression>=Fields!Employees.UniqueName</GroupExpression>
</GroupExpressions>
</Grouping>
</Details>
<Header>
<TableRows>
<TableRow>
<TableCells>
<TableCell>
<ReportItems>
<Textbox Name="textbox1">
<rd:DefaultName>textbox1</rd:DefaultName>
<ZIndex>14</ZIndex>
<Style>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
</Style>
<CanGrow>true</CanGrow>
<Value>Employees</Value>
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="textbox4">
<rd:DefaultName>textbox4</rd:DefaultName>
<ZIndex>13</ZIndex>
<Style>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
</Style>
<CanGrow>true</CanGrow>
<Value />
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="textbox2">
<rd:DefaultName>textbox2</rd:DefaultName>
<ZIndex>12</ZIndex>
<Style>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
</Style>
<CanGrow>true</CanGrow>
<Value />
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="textbox3">
<rd:DefaultName>textbox3</rd:DefaultName>
<ZIndex>11</ZIndex>
<Style>
<TextAlign>Center</TextAlign>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
</Style>
<CanGrow>true</CanGrow>
<Value>Level</Value>
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="textbox6">
<rd:DefaultName>textbox6</rd:DefaultName>
<ZIndex>10</ZIndex>
<Style>
<TextAlign>Right</TextAlign>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
</Style>
<CanGrow>true</CanGrow>
<Value>Reseller Sales Amount</Value>
</Textbox>
</ReportItems>
</TableCell>
</TableCells>
<Height>0.25in</Height>
</TableRow>
</TableRows>
</Header>
<TableColumns>
<TableColumn>
<Width>1.625in</Width>
</TableColumn>
<TableColumn>
<Width>0.875in</Width>
<Visibility>
<Hidden>true</Hidden>
</Visibility>
</TableColumn>
<TableColumn>
<Width>0.875in</Width>
<Visibility>
<Hidden>true</Hidden>
</Visibility>
</TableColumn>
<TableColumn>
<Width>0.5in</Width>
</TableColumn>
<TableColumn>
<Width>1.75in</Width>
</TableColumn>
</TableColumns>
<Height>0.75in</Height>
</Table>
</ReportItems>
<Height>1.375in</Height>
</Body>
<rd:ReportID>380d94a9-e8f4-4147-8f13-1f6d88259335</rd:ReportID>
<LeftMargin>1in</LeftMargin>
<DataSets>
<DataSet Name="DataSet1">
<Query>
<rd:SuppressAutoUpdate>true</rd:SuppressAutoUpdate>
<CommandText> SELECT NON EMPTY { [Measures].[Reseller Sales
Amount] } ON COLUMNS, NON EMPTY {
(DESCENDANTS([Employee].[Employees].[Employee Level 02].ALLMEMBERS) ) }
DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME, PARENT_UNIQUE_NAME,
LEVEL_NUMBER ON ROWS FROM [Adventure Works] CELL PROPERTIES VALUE,
BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME,
FONT_SIZE, FONT_FLAGS</CommandText>
<DataSourceName>DataSource1</DataSourceName>
<rd:MdxQuery><QueryDefinition
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="<CommandType>MDX</CommandType><QuerySpecification">http://schemas.microsoft.com/AnalysisServices/QueryDefinition"><CommandType>MDX</CommandType><QuerySpecification
xsi:type="MDXQuerySpecification"><Select><Items><Item><ID
xsi:type="Level"><DimensionName>Employee</DimensionName><HierarchyName>Employees</HierarchyName><HierarchyUniqueName>[Employee].[Employees]</HierarchyUniqueName><LevelName>Employee
Level 02</LevelName><UniqueName>[Employee].[Employees].[Employee Level
02]</UniqueName></ID><ItemCaption>Employees</ItemCaption><UniqueName>true</UniqueName><IsParentChild>true</IsParentChild></Item><Item><ID
xsi:type="Measure"><MeasureName>Reseller Sales
Amount</MeasureName><UniqueName>[Measures].[Reseller Sales
Amount]</UniqueName></ID><ItemCaption>Reseller Sales
Amount</ItemCaption><BackColor>true</BackColor><ForeColor>true</ForeColor><FontFamily>true</FontFamily><FontSize>true</FontSize><FontWeight>true</FontWeight><FontStyle>true</FontStyle><FontDecoration>true</FontDecoration><FormattedValue>true</FormattedValue><FormatString>true</FormatString></Item></Items></Select><From>Adventure
Works</From><Filter><FilterItems /></Filter><Calculations /><Aggregates
/><QueryProperties /></QuerySpecification><Query><Statement> SELECT NON
EMPTY { [Measures].[Reseller Sales Amount] } ON COLUMNS, NON EMPTY {
(DESCENDANTS([Employee].[Employees].[Employee Level 02].ALLMEMBERS) ) }
DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME, PARENT_UNIQUE_NAME,
LEVEL_NUMBER ON ROWS FROM [Adventure Works] CELL PROPERTIES VALUE,
BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME,
FONT_SIZE, FONT_FLAGS</Statement><ParameterDefinitions
/></Query></QueryDefinition></rd:MdxQuery>
</Query>
<Fields>
<Field Name="Employees">
<rd:TypeName>System.String</rd:TypeName>
<DataField><?xml version="1.0" encoding="utf-8"?><Field
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="Level"
UniqueName="[Employee].[Employees]" /></DataField>
</Field>
<Field Name="Reseller_Sales_Amount">
<rd:TypeName>System.Int32</rd:TypeName>
<DataField><?xml version="1.0" encoding="utf-8"?><Field
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="Measure"
UniqueName="[Measures].[Reseller Sales Amount]" /></DataField>
</Field>
</Fields>
</DataSet>
</DataSets>
<Width>5.625in</Width>
<InteractiveHeight>11in</InteractiveHeight>
<Language>en-US</Language>
<TopMargin>1in</TopMargin>
</Report>|||BTW: you don't need to have the two additional hidden table columns with
UniqueName and ParentUniqueName in the report (as shown in my sample). It is
sufficient to e.g. just change the expression in the first table column from
=Fields!Employees.Value to =Fields!Employees("Value"). This will turn off a
certain optimization related to extended field properties.
-- Robert
This posting is provided "AS IS" with no warranties, and confers no rights.
"Robert Bruckner [MSFT]" <robruc@.online.microsoft.com> wrote in message
news:e4fKfdq1FHA.2964@.TK2MSFTNGP09.phx.gbl...
>I attached a sample report that shows how to do this.
> Notes:
> * in the graphical query designer you have to select a recursive hierarchy
> from the cube (such as Employee.Employees in the AdventureWorks DW cube).
> Based on the metadata, RS should automatically detect that this is a
> recursive parent-child hierarchy and there will be additional extended
> field properties available (such as .UniqueName and .ParentUniqueName)
> * add a grouping in the report. The grouping expression is based on
> =Fields!Employees.UniqueName and for the parent of the group set it to
> =Fields!Employees.ParentUniqueName
> * right now, you will need to have table columns that also reference the
> UniqueName and the ParentUniqueName in the report - but you can hide them
> so they are not visible. If you don't have these columns, the recursive
> hierarchy won't work correctly.
> -- Robert
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
> "Raghu" <Raghu@.discussions.microsoft.com> wrote in message
> news:A3B4E2B3-B78D-4571-9D90-69EC03FD18E4@.microsoft.com...
>> I'm trying to use an OLAP cube as my data source (built using SSAS 2005)
>> The cube has a parent-child dimension and a fact table. I would like to
>> display the parent-child data in a report . Does anyone know how to build
>> an
>> MDX query that would give me the ID and the ParentID from the dimension
>> to
>> build the parent-child grouping relationship in the report? The MDX
>> builder
>> does not let me access the ID field or the ParentID field. I always get
>> the
>> Name of the dimension.
>> Also, if there's another way to do this, please let me know.
>> Any help is greatly appreciated.
>> Thanks
>
> ==========================================================> <?xml version="1.0" encoding="utf-8"?>
> <Report
> xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition"
> xmlns:rd="">http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
> <DataSources>
> <DataSource Name="DataSource1">
> <ConnectionProperties>
> <IntegratedSecurity>true</IntegratedSecurity>
> <ConnectString>Data Source=(local);Initial Catalog="Adventure Works
> DW"</ConnectString>
> <DataProvider>OLEDB-MD</DataProvider>
> </ConnectionProperties>
> <rd:DataSourceID>5aaa5577-4975-4616-a136-0b713dab6948</rd:DataSourceID>
> </DataSource>
> </DataSources>
> <BottomMargin>1in</BottomMargin>
> <RightMargin>1in</RightMargin>
> <rd:DrawGrid>true</rd:DrawGrid>
> <InteractiveWidth>8.5in</InteractiveWidth>
> <rd:SnapToGrid>true</rd:SnapToGrid>
> <Body>
> <ReportItems>
> <Table Name="table1">
> <Footer>
> <TableRows>
> <TableRow>
> <TableCells>
> <TableCell>
> <ReportItems>
> <Textbox Name="textbox7">
> <rd:DefaultName>textbox7</rd:DefaultName>
> <ZIndex>9</ZIndex>
> <Style>
> <PaddingLeft>2pt</PaddingLeft>
> <PaddingBottom>2pt</PaddingBottom>
> <PaddingRight>2pt</PaddingRight>
> <PaddingTop>2pt</PaddingTop>
> </Style>
> <CanGrow>true</CanGrow>
> <Value />
> </Textbox>
> </ReportItems>
> </TableCell>
> <TableCell>
> <ReportItems>
> <Textbox Name="textbox9">
> <rd:DefaultName>textbox9</rd:DefaultName>
> <ZIndex>8</ZIndex>
> <Style>
> <PaddingLeft>2pt</PaddingLeft>
> <PaddingBottom>2pt</PaddingBottom>
> <PaddingRight>2pt</PaddingRight>
> <PaddingTop>2pt</PaddingTop>
> </Style>
> <CanGrow>true</CanGrow>
> <Value />
> </Textbox>
> </ReportItems>
> </TableCell>
> <TableCell>
> <ReportItems>
> <Textbox Name="textbox8">
> <rd:DefaultName>textbox8</rd:DefaultName>
> <ZIndex>7</ZIndex>
> <Style>
> <PaddingLeft>2pt</PaddingLeft>
> <PaddingBottom>2pt</PaddingBottom>
> <PaddingRight>2pt</PaddingRight>
> <PaddingTop>2pt</PaddingTop>
> </Style>
> <CanGrow>true</CanGrow>
> <Value />
> </Textbox>
> </ReportItems>
> </TableCell>
> <TableCell>
> <ReportItems>
> <Textbox Name="textbox11">
> <rd:DefaultName>textbox11</rd:DefaultName>
> <ZIndex>6</ZIndex>
> <Style>
> <TextAlign>Center</TextAlign>
> <PaddingLeft>2pt</PaddingLeft>
> <PaddingBottom>2pt</PaddingBottom>
> <PaddingRight>2pt</PaddingRight>
> <PaddingTop>2pt</PaddingTop>
> </Style>
> <CanGrow>true</CanGrow>
> <Value />
> </Textbox>
> </ReportItems>
> </TableCell>
> <TableCell>
> <ReportItems>
> <Textbox Name="textbox13">
> <rd:DefaultName>textbox13</rd:DefaultName>
> <ZIndex>5</ZIndex>
> <Style>
> <PaddingLeft>2pt</PaddingLeft>
> <PaddingBottom>2pt</PaddingBottom>
> <PaddingRight>2pt</PaddingRight>
> <PaddingTop>2pt</PaddingTop>
> </Style>
> <CanGrow>true</CanGrow>
> <Value />
> </Textbox>
> </ReportItems>
> </TableCell>
> </TableCells>
> <Height>0.25in</Height>
> </TableRow>
> </TableRows>
> </Footer>
> <DataSetName>DataSet1</DataSetName>
> <Top>0.5in</Top>
> <Details>
> <TableRows>
> <TableRow>
> <TableCells>
> <TableCell>
> <ReportItems>
> <Textbox Name="Employees">
> <rd:DefaultName>Employees</rd:DefaultName>
> <ZIndex>4</ZIndex>
> <Style>
> <PaddingLeft>=2 + Level() * 8 &
> "pt"</PaddingLeft>
> <PaddingBottom>2pt</PaddingBottom>
> <PaddingRight>2pt</PaddingRight>
> <PaddingTop>2pt</PaddingTop>
> </Style>
> <CanGrow>true</CanGrow>
> <Value>=Fields!Employees.Value</Value>
> </Textbox>
> </ReportItems>
> </TableCell>
> <TableCell>
> <ReportItems>
> <Textbox Name="textbox10">
> <ZIndex>3</ZIndex>
> <Style>
> <PaddingLeft>2pt</PaddingLeft>
> <PaddingBottom>2pt</PaddingBottom>
> <PaddingRight>2pt</PaddingRight>
> <PaddingTop>2pt</PaddingTop>
> </Style>
> <CanGrow>true</CanGrow>
> <Value>=Fields!Employees.UniqueName</Value>
> </Textbox>
> </ReportItems>
> </TableCell>
> <TableCell>
> <ReportItems>
> <Textbox Name="textbox5">
> <rd:DefaultName>textbox5</rd:DefaultName>
> <ZIndex>2</ZIndex>
> <Style>
> <PaddingLeft>2pt</PaddingLeft>
> <PaddingBottom>2pt</PaddingBottom>
> <PaddingRight>2pt</PaddingRight>
> <PaddingTop>2pt</PaddingTop>
> </Style>
> <CanGrow>true</CanGrow>
> <Value>=Fields!Employees.ParentUniqueName</Value>
> </Textbox>
> </ReportItems>
> </TableCell>
> <TableCell>
> <ReportItems>
> <Textbox Name="Reseller_Sales_Amount">
> <rd:DefaultName>Reseller_Sales_Amount</rd:DefaultName>
> <ZIndex>1</ZIndex>
> <Style>
> <TextAlign>Center</TextAlign>
> <PaddingLeft>2pt</PaddingLeft>
> <PaddingBottom>2pt</PaddingBottom>
> <PaddingRight>2pt</PaddingRight>
> <PaddingTop>2pt</PaddingTop>
> </Style>
> <CanGrow>true</CanGrow>
> <Value>=Level()</Value>
> </Textbox>
> </ReportItems>
> </TableCell>
> <TableCell>
> <ReportItems>
> <Textbox Name="Reseller_Sales_Amount_1">
> <rd:DefaultName>Reseller_Sales_Amount_1</rd:DefaultName>
> <Style>
> <TextAlign>Right</TextAlign>
> <PaddingLeft>2pt</PaddingLeft>
> <PaddingBottom>2pt</PaddingBottom>
> <PaddingRight>2pt</PaddingRight>
> <PaddingTop>2pt</PaddingTop>
> </Style>
> <CanGrow>true</CanGrow>
> <Value>=Sum(Fields!Reseller_Sales_Amount.Value)</Value>
> </Textbox>
> </ReportItems>
> </TableCell>
> </TableCells>
> <Height>0.25in</Height>
> </TableRow>
> </TableRows>
> <Grouping Name="table1_Details_Group">
> <Parent>=Fields!Employees.ParentUniqueName</Parent>
> <GroupExpressions>
> <GroupExpression>=Fields!Employees.UniqueName</GroupExpression>
> </GroupExpressions>
> </Grouping>
> </Details>
> <Header>
> <TableRows>
> <TableRow>
> <TableCells>
> <TableCell>
> <ReportItems>
> <Textbox Name="textbox1">
> <rd:DefaultName>textbox1</rd:DefaultName>
> <ZIndex>14</ZIndex>
> <Style>
> <PaddingLeft>2pt</PaddingLeft>
> <PaddingBottom>2pt</PaddingBottom>
> <PaddingRight>2pt</PaddingRight>
> <PaddingTop>2pt</PaddingTop>
> </Style>
> <CanGrow>true</CanGrow>
> <Value>Employees</Value>
> </Textbox>
> </ReportItems>
> </TableCell>
> <TableCell>
> <ReportItems>
> <Textbox Name="textbox4">
> <rd:DefaultName>textbox4</rd:DefaultName>
> <ZIndex>13</ZIndex>
> <Style>
> <PaddingLeft>2pt</PaddingLeft>
> <PaddingBottom>2pt</PaddingBottom>
> <PaddingRight>2pt</PaddingRight>
> <PaddingTop>2pt</PaddingTop>
> </Style>
> <CanGrow>true</CanGrow>
> <Value />
> </Textbox>
> </ReportItems>
> </TableCell>
> <TableCell>
> <ReportItems>
> <Textbox Name="textbox2">
> <rd:DefaultName>textbox2</rd:DefaultName>
> <ZIndex>12</ZIndex>
> <Style>
> <PaddingLeft>2pt</PaddingLeft>
> <PaddingBottom>2pt</PaddingBottom>
> <PaddingRight>2pt</PaddingRight>
> <PaddingTop>2pt</PaddingTop>
> </Style>
> <CanGrow>true</CanGrow>
> <Value />
> </Textbox>
> </ReportItems>
> </TableCell>
> <TableCell>
> <ReportItems>
> <Textbox Name="textbox3">
> <rd:DefaultName>textbox3</rd:DefaultName>
> <ZIndex>11</ZIndex>
> <Style>
> <TextAlign>Center</TextAlign>
> <PaddingLeft>2pt</PaddingLeft>
> <PaddingBottom>2pt</PaddingBottom>
> <PaddingRight>2pt</PaddingRight>
> <PaddingTop>2pt</PaddingTop>
> </Style>
> <CanGrow>true</CanGrow>
> <Value>Level</Value>
> </Textbox>
> </ReportItems>
> </TableCell>
> <TableCell>
> <ReportItems>
> <Textbox Name="textbox6">
> <rd:DefaultName>textbox6</rd:DefaultName>
> <ZIndex>10</ZIndex>
> <Style>
> <TextAlign>Right</TextAlign>
> <PaddingLeft>2pt</PaddingLeft>
> <PaddingBottom>2pt</PaddingBottom>
> <PaddingRight>2pt</PaddingRight>
> <PaddingTop>2pt</PaddingTop>
> </Style>
> <CanGrow>true</CanGrow>
> <Value>Reseller Sales Amount</Value>
> </Textbox>
> </ReportItems>
> </TableCell>
> </TableCells>
> <Height>0.25in</Height>
> </TableRow>
> </TableRows>
> </Header>
> <TableColumns>
> <TableColumn>
> <Width>1.625in</Width>
> </TableColumn>
> <TableColumn>
> <Width>0.875in</Width>
> <Visibility>
> <Hidden>true</Hidden>
> </Visibility>
> </TableColumn>
> <TableColumn>
> <Width>0.875in</Width>
> <Visibility>
> <Hidden>true</Hidden>
> </Visibility>
> </TableColumn>
> <TableColumn>
> <Width>0.5in</Width>
> </TableColumn>
> <TableColumn>
> <Width>1.75in</Width>
> </TableColumn>
> </TableColumns>
> <Height>0.75in</Height>
> </Table>
> </ReportItems>
> <Height>1.375in</Height>
> </Body>
> <rd:ReportID>380d94a9-e8f4-4147-8f13-1f6d88259335</rd:ReportID>
> <LeftMargin>1in</LeftMargin>
> <DataSets>
> <DataSet Name="DataSet1">
> <Query>
> <rd:SuppressAutoUpdate>true</rd:SuppressAutoUpdate>
> <CommandText> SELECT NON EMPTY { [Measures].[Reseller Sales
> Amount] } ON COLUMNS, NON EMPTY {
> (DESCENDANTS([Employee].[Employees].[Employee Level 02].ALLMEMBERS) ) }
> DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME,
> PARENT_UNIQUE_NAME, LEVEL_NUMBER ON ROWS FROM [Adventure Works] CELL
> PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING,
> FONT_NAME, FONT_SIZE, FONT_FLAGS</CommandText>
> <DataSourceName>DataSource1</DataSourceName>
> <rd:MdxQuery><QueryDefinition
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns="<CommandType>MDX</CommandType><QuerySpecification">http://schemas.microsoft.com/AnalysisServices/QueryDefinition"><CommandType>MDX</CommandType><QuerySpecification
> xsi:type="MDXQuerySpecification"><Select><Items><Item><ID
> xsi:type="Level"><DimensionName>Employee</DimensionName><HierarchyName>Employees</HierarchyName><HierarchyUniqueName>[Employee].[Employees]</HierarchyUniqueName><LevelName>Employee
> Level 02</LevelName><UniqueName>[Employee].[Employees].[Employee Level
> 02]</UniqueName></ID><ItemCaption>Employees</ItemCaption><UniqueName>true</UniqueName><IsParentChild>true</IsParentChild></Item><Item><ID
> xsi:type="Measure"><MeasureName>Reseller Sales
> Amount</MeasureName><UniqueName>[Measures].[Reseller Sales
> Amount]</UniqueName></ID><ItemCaption>Reseller Sales
> Amount</ItemCaption><BackColor>true</BackColor><ForeColor>true</ForeColor><FontFamily>true</FontFamily><FontSize>true</FontSize><FontWeight>true</FontWeight><FontStyle>true</FontStyle><FontDecoration>true</FontDecoration><FormattedValue>true</FormattedValue><FormatString>true</FormatString></Item></Items></Select><From>Adventure
> Works</From><Filter><FilterItems /></Filter><Calculations /><Aggregates
> /><QueryProperties /></QuerySpecification><Query><Statement> SELECT NON
> EMPTY { [Measures].[Reseller Sales Amount] } ON COLUMNS, NON EMPTY {
> (DESCENDANTS([Employee].[Employees].[Employee Level 02].ALLMEMBERS) ) }
> DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME,
> PARENT_UNIQUE_NAME, LEVEL_NUMBER ON ROWS FROM [Adventure Works] CELL
> PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING,
> FONT_NAME, FONT_SIZE, FONT_FLAGS</Statement><ParameterDefinitions
> /></Query></QueryDefinition></rd:MdxQuery>
> </Query>
> <Fields>
> <Field Name="Employees">
> <rd:TypeName>System.String</rd:TypeName>
> <DataField><?xml version="1.0" encoding="utf-8"?><Field
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="Level"
> UniqueName="[Employee].[Employees]" /></DataField>
> </Field>
> <Field Name="Reseller_Sales_Amount">
> <rd:TypeName>System.Int32</rd:TypeName>
> <DataField><?xml version="1.0" encoding="utf-8"?><Field
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="Measure"
> UniqueName="[Measures].[Reseller Sales Amount]" /></DataField>
> </Field>
> </Fields>
> </DataSet>
> </DataSets>
> <Width>5.625in</Width>
> <InteractiveHeight>11in</InteractiveHeight>
> <Language>en-US</Language>
> <TopMargin>1in</TopMargin>
> </Report>
>|||Thank you Robert, that was very helpful. I got past a hurdle. I do have a
couple of folllowup questions inspired by your response (and my somewhat
novice knowledge of OLAP).
Raghu
--
1. Dimension properties MEMBER_UNIQUE_NAME and PARENT_UNIQUE_NAME do get
added in the MDX as you mention. Any idea why they don't show up as fields in
the dataset? Your grouping expression used Employee.UniqueName. How are we
to know what the name of those fields are? Should we just strip of the MEMBER
keyword and any underscores and use as field names, or is there a list
somewhere? I'll try to search the docs as well. Also, when I tried to use
MEMBER_KEY property, it showed up in the result set unlike the others.
2. The grouping is based on names, which are a character based. Would this
affect performance adversely if the report data is large? One of the reasons
I wanted to use IDs was due to the names not being unique (But
MEMBER_UNIQUE_NAME seems to imply that Analysis services is generating one in
internally.)
3. I was somewhat surprised at the difference in behavior when we use
Employees("Value") and Employees.Value. Could you please shed some more light
on this as to what's happening here? I think when you use the first method,
you are basically using the indexer property in VB.NET syntax (please correct
me if I'm wrong.), but that's as far as I could get. Is this behavior
documented somewhere?
"Robert Bruckner [MSFT]" wrote:
> BTW: you don't need to have the two additional hidden table columns with
> UniqueName and ParentUniqueName in the report (as shown in my sample). It is
> sufficient to e.g. just change the expression in the first table column from
> =Fields!Employees.Value to =Fields!Employees("Value"). This will turn off a
> certain optimization related to extended field properties.
> -- Robert
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> "Robert Bruckner [MSFT]" <robruc@.online.microsoft.com> wrote in message
> news:e4fKfdq1FHA.2964@.TK2MSFTNGP09.phx.gbl...
> >I attached a sample report that shows how to do this.
> > Notes:
> > * in the graphical query designer you have to select a recursive hierarchy
> > from the cube (such as Employee.Employees in the AdventureWorks DW cube).
> > Based on the metadata, RS should automatically detect that this is a
> > recursive parent-child hierarchy and there will be additional extended
> > field properties available (such as .UniqueName and .ParentUniqueName)
> > * add a grouping in the report. The grouping expression is based on
> > =Fields!Employees.UniqueName and for the parent of the group set it to
> > =Fields!Employees.ParentUniqueName
> > * right now, you will need to have table columns that also reference the
> > UniqueName and the ParentUniqueName in the report - but you can hide them
> > so they are not visible. If you don't have these columns, the recursive
> > hierarchy won't work correctly.
> >
> > -- Robert
> > This posting is provided "AS IS" with no warranties, and confers no
> > rights.
> >
> >
> > "Raghu" <Raghu@.discussions.microsoft.com> wrote in message
> > news:A3B4E2B3-B78D-4571-9D90-69EC03FD18E4@.microsoft.com...
> >> I'm trying to use an OLAP cube as my data source (built using SSAS 2005)
> >> The cube has a parent-child dimension and a fact table. I would like to
> >> display the parent-child data in a report . Does anyone know how to build
> >> an
> >> MDX query that would give me the ID and the ParentID from the dimension
> >> to
> >> build the parent-child grouping relationship in the report? The MDX
> >> builder
> >> does not let me access the ID field or the ParentID field. I always get
> >> the
> >> Name of the dimension.
> >>
> >> Also, if there's another way to do this, please let me know.
> >>
> >> Any help is greatly appreciated.
> >>
> >> Thanks
> >
> >
> > ==========================================================> >
> > <?xml version="1.0" encoding="utf-8"?>
> > <Report
> > xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition"
> > xmlns:rd="">http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
> > <DataSources>
> > <DataSource Name="DataSource1">
> > <ConnectionProperties>
> > <IntegratedSecurity>true</IntegratedSecurity>
> > <ConnectString>Data Source=(local);Initial Catalog="Adventure Works
> > DW"</ConnectString>
> > <DataProvider>OLEDB-MD</DataProvider>
> > </ConnectionProperties>
> >
> > <rd:DataSourceID>5aaa5577-4975-4616-a136-0b713dab6948</rd:DataSourceID>
> > </DataSource>
> > </DataSources>
> > <BottomMargin>1in</BottomMargin>
> > <RightMargin>1in</RightMargin>
> > <rd:DrawGrid>true</rd:DrawGrid>
> > <InteractiveWidth>8.5in</InteractiveWidth>
> > <rd:SnapToGrid>true</rd:SnapToGrid>
> > <Body>
> > <ReportItems>
> > <Table Name="table1">
> > <Footer>
> > <TableRows>
> > <TableRow>
> > <TableCells>
> > <TableCell>
> > <ReportItems>
> > <Textbox Name="textbox7">
> > <rd:DefaultName>textbox7</rd:DefaultName>
> > <ZIndex>9</ZIndex>
> > <Style>
> > <PaddingLeft>2pt</PaddingLeft>
> > <PaddingBottom>2pt</PaddingBottom>
> > <PaddingRight>2pt</PaddingRight>
> > <PaddingTop>2pt</PaddingTop>
> > </Style>
> > <CanGrow>true</CanGrow>
> > <Value />
> > </Textbox>
> > </ReportItems>
> > </TableCell>
> > <TableCell>
> > <ReportItems>
> > <Textbox Name="textbox9">
> > <rd:DefaultName>textbox9</rd:DefaultName>
> > <ZIndex>8</ZIndex>
> > <Style>
> > <PaddingLeft>2pt</PaddingLeft>
> > <PaddingBottom>2pt</PaddingBottom>
> > <PaddingRight>2pt</PaddingRight>
> > <PaddingTop>2pt</PaddingTop>
> > </Style>
> > <CanGrow>true</CanGrow>
> > <Value />
> > </Textbox>
> > </ReportItems>
> > </TableCell>
> > <TableCell>
> > <ReportItems>
> > <Textbox Name="textbox8">
> > <rd:DefaultName>textbox8</rd:DefaultName>
> > <ZIndex>7</ZIndex>
> > <Style>
> > <PaddingLeft>2pt</PaddingLeft>
> > <PaddingBottom>2pt</PaddingBottom>
> > <PaddingRight>2pt</PaddingRight>
> > <PaddingTop>2pt</PaddingTop>
> > </Style>
> > <CanGrow>true</CanGrow>
> > <Value />
> > </Textbox>
> > </ReportItems>
> > </TableCell>
> > <TableCell>
> > <ReportItems>
> > <Textbox Name="textbox11">
> > <rd:DefaultName>textbox11</rd:DefaultName>
> > <ZIndex>6</ZIndex>
> > <Style>
> > <TextAlign>Center</TextAlign>
> > <PaddingLeft>2pt</PaddingLeft>
> > <PaddingBottom>2pt</PaddingBottom>
> > <PaddingRight>2pt</PaddingRight>
> > <PaddingTop>2pt</PaddingTop>
> > </Style>
> > <CanGrow>true</CanGrow>
> > <Value />
> > </Textbox>
> > </ReportItems>
> > </TableCell>
> > <TableCell>
> > <ReportItems>
> > <Textbox Name="textbox13">
> > <rd:DefaultName>textbox13</rd:DefaultName>
> > <ZIndex>5</ZIndex>
> > <Style>
> > <PaddingLeft>2pt</PaddingLeft>
> > <PaddingBottom>2pt</PaddingBottom>
> > <PaddingRight>2pt</PaddingRight>
> > <PaddingTop>2pt</PaddingTop>
> > </Style>
> > <CanGrow>true</CanGrow>
> > <Value />
> > </Textbox>
> > </ReportItems>
> > </TableCell>
> > </TableCells>
> > <Height>0.25in</Height>
> > </TableRow>
> > </TableRows>
> > </Footer>
> > <DataSetName>DataSet1</DataSetName>
> > <Top>0.5in</Top>
> > <Details>
> > <TableRows>
> > <TableRow>
> > <TableCells>
> > <TableCell>
> > <ReportItems>
> > <Textbox Name="Employees">
> > <rd:DefaultName>Employees</rd:DefaultName>
> > <ZIndex>4</ZIndex>
> > <Style>
> > <PaddingLeft>=2 + Level() * 8 &
> > "pt"</PaddingLeft>
> > <PaddingBottom>2pt</PaddingBottom>
> > <PaddingRight>2pt</PaddingRight>
> > <PaddingTop>2pt</PaddingTop>
> > </Style>
> > <CanGrow>true</CanGrow>
> > <Value>=Fields!Employees.Value</Value>
> > </Textbox>
> > </ReportItems>
> > </TableCell>
> > <TableCell>
> > <ReportItems>
> > <Textbox Name="textbox10">
> > <ZIndex>3</ZIndex>
> > <Style>
> > <PaddingLeft>2pt</PaddingLeft>
> > <PaddingBottom>2pt</PaddingBottom>
> > <PaddingRight>2pt</PaddingRight>
> > <PaddingTop>2pt</PaddingTop>
> > </Style>
> > <CanGrow>true</CanGrow>
> > <Value>=Fields!Employees.UniqueName</Value>
> > </Textbox>
> > </ReportItems>
> > </TableCell>
> > <TableCell>
> > <ReportItems>
> > <Textbox Name="textbox5">
> > <rd:DefaultName>textbox5</rd:DefaultName>
> > <ZIndex>2</ZIndex>
> > <Style>
> > <PaddingLeft>2pt</PaddingLeft>
> > <PaddingBottom>2pt</PaddingBottom>
> > <PaddingRight>2pt</PaddingRight>
> > <PaddingTop>2pt</PaddingTop>
> > </Style>
> > <CanGrow>true</CanGrow>
> > <Value>=Fields!Employees.ParentUniqueName</Value>
> > </Textbox>
> > </ReportItems>
> > </TableCell>
> > <TableCell>
> > <ReportItems>
> > <Textbox Name="Reseller_Sales_Amount">
> >
> > <rd:DefaultName>Reseller_Sales_Amount</rd:DefaultName>
> > <ZIndex>1</ZIndex>
> > <Style>
> > <TextAlign>Center</TextAlign>
> > <PaddingLeft>2pt</PaddingLeft>
> > <PaddingBottom>2pt</PaddingBottom>
> > <PaddingRight>2pt</PaddingRight>
> > <PaddingTop>2pt</PaddingTop>
> > </Style>
> > <CanGrow>true</CanGrow>
> > <Value>=Level()</Value>
> > </Textbox>
> > </ReportItems>
> > </TableCell>
> > <TableCell>
> > <ReportItems>
> > <Textbox Name="Reseller_Sales_Amount_1">
> >
> > <rd:DefaultName>Reseller_Sales_Amount_1</rd:DefaultName>
> > <Style>
> > <TextAlign>Right</TextAlign>
> > <PaddingLeft>2pt</PaddingLeft>
> > <PaddingBottom>2pt</PaddingBottom>
> > <PaddingRight>2pt</PaddingRight>
> > <PaddingTop>2pt</PaddingTop>
> > </Style>
> > <CanGrow>true</CanGrow>
> >
> > <Value>=Sum(Fields!Reseller_Sales_Amount.Value)</Value>
> > </Textbox>
> > </ReportItems>
> > </TableCell>
> > </TableCells>
> > <Height>0.25in</Height>
> > </TableRow>
> > </TableRows>
> > <Grouping Name="table1_Details_Group">
> > <Parent>=Fields!Employees.ParentUniqueName</Parent>
> > <GroupExpressions>
> >
> > <GroupExpression>=Fields!Employees.UniqueName</GroupExpression>
> > </GroupExpressions>
> > </Grouping>
> > </Details>
> > <Header>
> > <TableRows>
> > <TableRow>
> > <TableCells>
> > <TableCell>
> > <ReportItems>
> > <Textbox Name="textbox1">
> > <rd:DefaultName>textbox1</rd:DefaultName>
> > <ZIndex>14</ZIndex>
> > <Style>
> > <PaddingLeft>2pt</PaddingLeft>
> > <PaddingBottom>2pt</PaddingBottom>
> > <PaddingRight>2pt</PaddingRight>
> > <PaddingTop>2pt</PaddingTop>
> > </Style>
> > <CanGrow>true</CanGrow>
> > <Value>Employees</Value>
> > </Textbox>
> > </ReportItems>
> > </TableCell>
> > <TableCell>
> > <ReportItems>
> > <Textbox Name="textbox4">
> > <rd:DefaultName>textbox4</rd:DefaultName>
> > <ZIndex>13</ZIndex>
> > <Style>
> > <PaddingLeft>2pt</PaddingLeft>
> > <PaddingBottom>2pt</PaddingBottom>
> > <PaddingRight>2pt</PaddingRight>|||#1: AS dimension properties (such as Member_Unique_Name) and cell properties
(such as Formatted_Value) automatically get translated into RDL extended
properties. Please check the "Using Extended Field Properties for Analysis
Services Data" in RS 2005 Books Online (e.g. at
http://msdn2.microsoft.com/en-us/library/ms156477). Consequently, they are
just field properties instead of additional fields (as they used to be in RS
2000 through the old OleDB provider for AS 2000). Here is the
mapping/translation for the predefined RDL field properties that happens
inside our AdoMd AS data extension:
RDL field property name: Type / AS translation:
Value Object (from Member_Caption)
IsMissing Boolean (field is defined in RDL but
not returned from query)
UniqueName String (from Member_Unique_Name)
BackgroundColor String (see Style.BackgroundColor; retrieved
from Back_Color)
Color String (see Style.Color; retrieved
from Fore_Color)
FontFamily String (see Style.FontFamily; retrieved
from Font_Name)
FontSize String (see Style.FontSize; retrieved
from Font_Size)
FontWeight String (see Style.FontWeight; retrieved
from Font_Flags)
FontStyle String (see Style.FontStyle;
retrieved from Font_Flags)
TextDecoration String (see Style.TextDecoration;
retrieved from Font_Flags)
FormattedValue String (from Formatted_Value)
Key Object (this is supposed to be
retrieved from Member_Key; however right now you have to use the collection
syntax to retrieve the value as =Fields!MemberName("Member_Key") )
LevelNumber Integer (from Level_Number)
ParentUniqueName String (from Parent_Unique_Name)
Note: the Member_Key field that shows up in the designer fields list won't
be mapped correctly at report execution. Therefore the value will just be
NULL right now. You have to use the following syntax to retrieve the value:
=Fields!MemberName("Member_Key").
#2: You could define custom properties (IDs) in your cube and retrieve them
through the MDX query (not sure which steps are exactly needed to set this
up in your cube - you may want to lookup AS 2005 BOL). These custom
properties would not get mapped to predefined property names. Therefore, you
would need to use the property collection syntax to access them, e.g.
=Fields!MemberName("MyID"). Note: even if your ids are numbers, I believe
the AS data provider will return them as strings. Anyway, you could then use
e.g. =CInt(Fields!MemberName("MyID")) for the grouping.
#3: In general, there is no difference in behavior for these expressions:
=Fields!FieldName.PropertyName -- static field/property reference
=Fields("FieldName").PropertyName -- dynamic field reference
=Fields!FieldName("PropertyName") -- dynamic property reference
=Fields(Fields!SomeOtherField.Value).PropertyName -- dynamic field name is
determined by the value of another field
However, we implemented several levels of performance optimizations that
would e.g. only retrieve those property values that are really used in the
report (e.g. if you use static references only throughout the entire
report). Using a dynamic property reference will turn off the optimization
for a certain field. Due to a bug, the usage of ParentUniqueName
specifically in the parent-child recursive grouping is not detected. By
using the dynamic property reference, you turn off the optimization, we will
retrieve the ParentUniqueName property value for the field also, and
everything will work. The fix for the detection will be included in a
service pack - in the meantime, just use the dynamic property reference to
turn off the optimization.
We will look into making the extended properties more "discoverable" through
visual indications at report design time in future releases. This includes
detecting/setting up recursive hierarchies more easily from AS data.
Hope this answers your questions,
-- Robert
This posting is provided "AS IS" with no warranties, and confers no rights.
"Raghu" <Raghu@.discussions.microsoft.com> wrote in message
news:25F0BE41-DDA1-491E-9043-A7E36AA633E7@.microsoft.com...
> Thank you Robert, that was very helpful. I got past a hurdle. I do have a
> couple of folllowup questions inspired by your response (and my somewhat
> novice knowledge of OLAP).
> Raghu
> --
> 1. Dimension properties MEMBER_UNIQUE_NAME and PARENT_UNIQUE_NAME do get
> added in the MDX as you mention. Any idea why they don't show up as fields
> in
> the dataset? Your grouping expression used Employee.UniqueName. How are
> we
> to know what the name of those fields are? Should we just strip of the
> MEMBER
> keyword and any underscores and use as field names, or is there a list
> somewhere? I'll try to search the docs as well. Also, when I tried to use
> MEMBER_KEY property, it showed up in the result set unlike the others.
> 2. The grouping is based on names, which are a character based. Would this
> affect performance adversely if the report data is large? One of the
> reasons
> I wanted to use IDs was due to the names not being unique (But
> MEMBER_UNIQUE_NAME seems to imply that Analysis services is generating one
> in
> internally.)
> 3. I was somewhat surprised at the difference in behavior when we use
> Employees("Value") and Employees.Value. Could you please shed some more
> light
> on this as to what's happening here? I think when you use the first
> method,
> you are basically using the indexer property in VB.NET syntax (please
> correct
> me if I'm wrong.), but that's as far as I could get. Is this behavior
> documented somewhere?
> "Robert Bruckner [MSFT]" wrote:
>> BTW: you don't need to have the two additional hidden table columns with
>> UniqueName and ParentUniqueName in the report (as shown in my sample). It
>> is
>> sufficient to e.g. just change the expression in the first table column
>> from
>> =Fields!Employees.Value to =Fields!Employees("Value"). This will turn off
>> a
>> certain optimization related to extended field properties.
>> -- Robert
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>>
>> "Robert Bruckner [MSFT]" <robruc@.online.microsoft.com> wrote in message
>> news:e4fKfdq1FHA.2964@.TK2MSFTNGP09.phx.gbl...
>> >I attached a sample report that shows how to do this.
>> > Notes:
>> > * in the graphical query designer you have to select a recursive
>> > hierarchy
>> > from the cube (such as Employee.Employees in the AdventureWorks DW
>> > cube).
>> > Based on the metadata, RS should automatically detect that this is a
>> > recursive parent-child hierarchy and there will be additional extended
>> > field properties available (such as .UniqueName and .ParentUniqueName)
>> > * add a grouping in the report. The grouping expression is based on
>> > =Fields!Employees.UniqueName and for the parent of the group set it to
>> > =Fields!Employees.ParentUniqueName
>> > * right now, you will need to have table columns that also reference
>> > the
>> > UniqueName and the ParentUniqueName in the report - but you can hide
>> > them
>> > so they are not visible. If you don't have these columns, the recursive
>> > hierarchy won't work correctly.
>> >
>> > -- Robert
>> > This posting is provided "AS IS" with no warranties, and confers no
>> > rights.
>> >
>> >
>> > "Raghu" <Raghu@.discussions.microsoft.com> wrote in message
>> > news:A3B4E2B3-B78D-4571-9D90-69EC03FD18E4@.microsoft.com...
>> >> I'm trying to use an OLAP cube as my data source (built using SSAS
>> >> 2005)
>> >> The cube has a parent-child dimension and a fact table. I would like
>> >> to
>> >> display the parent-child data in a report . Does anyone know how to
>> >> build
>> >> an
>> >> MDX query that would give me the ID and the ParentID from the
>> >> dimension
>> >> to
>> >> build the parent-child grouping relationship in the report? The MDX
>> >> builder
>> >> does not let me access the ID field or the ParentID field. I always
>> >> get
>> >> the
>> >> Name of the dimension.
>> >>
>> >> Also, if there's another way to do this, please let me know.
>> >>
>> >> Any help is greatly appreciated.
>> >>
>> >> Thanks
>> >
>> >
>> > ==========================================================>> >
>> > <?xml version="1.0" encoding="utf-8"?>
>> > <Report
>> > xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition"
>> > xmlns:rd="">http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
>> > <DataSources>
>> > <DataSource Name="DataSource1">
>> > <ConnectionProperties>
>> > <IntegratedSecurity>true</IntegratedSecurity>
>> > <ConnectString>Data Source=(local);Initial Catalog="Adventure
>> > Works
>> > DW"</ConnectString>
>> > <DataProvider>OLEDB-MD</DataProvider>
>> > </ConnectionProperties>
>> >
>> > <rd:DataSourceID>5aaa5577-4975-4616-a136-0b713dab6948</rd:DataSourceID>
>> > </DataSource>
>> > </DataSources>
>> > <BottomMargin>1in</BottomMargin>
>> > <RightMargin>1in</RightMargin>
>> > <rd:DrawGrid>true</rd:DrawGrid>
>> > <InteractiveWidth>8.5in</InteractiveWidth>
>> > <rd:SnapToGrid>true</rd:SnapToGrid>
>> > <Body>
>> > <ReportItems>
>> > <Table Name="table1">
>> > <Footer>
>> > <TableRows>
>> > <TableRow>
>> > <TableCells>
>> > <TableCell>
>> > <ReportItems>
>> > <Textbox Name="textbox7">
>> > <rd:DefaultName>textbox7</rd:DefaultName>
>> > <ZIndex>9</ZIndex>
>> > <Style>
>> > <PaddingLeft>2pt</PaddingLeft>
>> > <PaddingBottom>2pt</PaddingBottom>
>> > <PaddingRight>2pt</PaddingRight>
>> > <PaddingTop>2pt</PaddingTop>
>> > </Style>
>> > <CanGrow>true</CanGrow>
>> > <Value />
>> > </Textbox>
>> > </ReportItems>
>> > </TableCell>
>> > <TableCell>
>> > <ReportItems>
>> > <Textbox Name="textbox9">
>> > <rd:DefaultName>textbox9</rd:DefaultName>
>> > <ZIndex>8</ZIndex>
>> > <Style>
>> > <PaddingLeft>2pt</PaddingLeft>
>> > <PaddingBottom>2pt</PaddingBottom>
>> > <PaddingRight>2pt</PaddingRight>
>> > <PaddingTop>2pt</PaddingTop>
>> > </Style>
>> > <CanGrow>true</CanGrow>
>> > <Value />
>> > </Textbox>
>> > </ReportItems>
>> > </TableCell>
>> > <TableCell>
>> > <ReportItems>
>> > <Textbox Name="textbox8">
>> > <rd:DefaultName>textbox8</rd:DefaultName>
>> > <ZIndex>7</ZIndex>
>> > <Style>
>> > <PaddingLeft>2pt</PaddingLeft>
>> > <PaddingBottom>2pt</PaddingBottom>
>> > <PaddingRight>2pt</PaddingRight>
>> > <PaddingTop>2pt</PaddingTop>
>> > </Style>
>> > <CanGrow>true</CanGrow>
>> > <Value />
>> > </Textbox>
>> > </ReportItems>
>> > </TableCell>
>> > <TableCell>
>> > <ReportItems>
>> > <Textbox Name="textbox11">
>> > <rd:DefaultName>textbox11</rd:DefaultName>
>> > <ZIndex>6</ZIndex>
>> > <Style>
>> > <TextAlign>Center</TextAlign>
>> > <PaddingLeft>2pt</PaddingLeft>
>> > <PaddingBottom>2pt</PaddingBottom>
>> > <PaddingRight>2pt</PaddingRight>
>> > <PaddingTop>2pt</PaddingTop>
>> > </Style>
>> > <CanGrow>true</CanGrow>
>> > <Value />
>> > </Textbox>
>> > </ReportItems>
>> > </TableCell>
>> > <TableCell>
>> > <ReportItems>
>> > <Textbox Name="textbox13">
>> > <rd:DefaultName>textbox13</rd:DefaultName>
>> > <ZIndex>5</ZIndex>
>> > <Style>
>> > <PaddingLeft>2pt</PaddingLeft>
>> > <PaddingBottom>2pt</PaddingBottom>
>> > <PaddingRight>2pt</PaddingRight>
>> > <PaddingTop>2pt</PaddingTop>
>> > </Style>
>> > <CanGrow>true</CanGrow>
>> > <Value />
>> > </Textbox>
>> > </ReportItems>
>> > </TableCell>
>> > </TableCells>
>> > <Height>0.25in</Height>
>> > </TableRow>
>> > </TableRows>
>> > </Footer>
>> > <DataSetName>DataSet1</DataSetName>
>> > <Top>0.5in</Top>
>> > <Details>
>> > <TableRows>
>> > <TableRow>
>> > <TableCells>
>> > <TableCell>
>> > <ReportItems>
>> > <Textbox Name="Employees">
>> > <rd:DefaultName>Employees</rd:DefaultName>
>> > <ZIndex>4</ZIndex>
>> > <Style>
>> > <PaddingLeft>=2 + Level() * 8 &
>> > "pt"</PaddingLeft>
>> > <PaddingBottom>2pt</PaddingBottom>
>> > <PaddingRight>2pt</PaddingRight>
>> > <PaddingTop>2pt</PaddingTop>
>> > </Style>
>> > <CanGrow>true</CanGrow>
>> > <Value>=Fields!Employees.Value</Value>
>> > </Textbox>
>> > </ReportItems>
>> > </TableCell>
>> > <TableCell>
>> > <ReportItems>
>> > <Textbox Name="textbox10">
>> > <ZIndex>3</ZIndex>
>> > <Style>
>> > <PaddingLeft>2pt</PaddingLeft>
>> > <PaddingBottom>2pt</PaddingBottom>
>> > <PaddingRight>2pt</PaddingRight>
>> > <PaddingTop>2pt</PaddingTop>
>> > </Style>
>> > <CanGrow>true</CanGrow>
>> > <Value>=Fields!Employees.UniqueName</Value>
>> > </Textbox>
>> > </ReportItems>
>> > </TableCell>
>> > <TableCell>
>> > <ReportItems>
>> > <Textbox Name="textbox5">
>> > <rd:DefaultName>textbox5</rd:DefaultName>
>> > <ZIndex>2</ZIndex>
>> > <Style>
>> > <PaddingLeft>2pt</PaddingLeft>
>> > <PaddingBottom>2pt</PaddingBottom>
>> > <PaddingRight>2pt</PaddingRight>
>> > <PaddingTop>2pt</PaddingTop>
>> > </Style>
>> > <CanGrow>true</CanGrow>
>> > <Value>=Fields!Employees.ParentUniqueName</Value>
>> > </Textbox>
>> > </ReportItems>
>> > </TableCell>
>> > <TableCell>
>> > <ReportItems>
>> > <Textbox Name="Reseller_Sales_Amount">
>> >
>> > <rd:DefaultName>Reseller_Sales_Amount</rd:DefaultName>
>> > <ZIndex>1</ZIndex>
>> > <Style>
>> > <TextAlign>Center</TextAlign>
>> > <PaddingLeft>2pt</PaddingLeft>
>> > <PaddingBottom>2pt</PaddingBottom>
>> > <PaddingRight>2pt</PaddingRight>
>> > <PaddingTop>2pt</PaddingTop>
>> > </Style>
>> > <CanGrow>true</CanGrow>
>> > <Value>=Level()</Value>
>> > </Textbox>
>> > </ReportItems>
>> > </TableCell>
>> > <TableCell>
>> > <ReportItems>
>> > <Textbox Name="Reseller_Sales_Amount_1">
>> >
>> > <rd:DefaultName>Reseller_Sales_Amount_1</rd:DefaultName>
>> > <Style>
>> > <TextAlign>Right</TextAlign>
>> > <PaddingLeft>2pt</PaddingLeft>
>> > <PaddingBottom>2pt</PaddingBottom>
>> > <PaddingRight>2pt</PaddingRight>
>> > <PaddingTop>2pt</PaddingTop>
>> > </Style>
>> > <CanGrow>true</CanGrow>
>> >
>> > <Value>=Sum(Fields!Reseller_Sales_Amount.Value)</Value>
>> > </Textbox>
>> > </ReportItems>
>> > </TableCell>
>> > </TableCells>
>> > <Height>0.25in</Height>
>> > </TableRow>
>> > </TableRows>
>> > <Grouping Name="table1_Details_Group">
>> > <Parent>=Fields!Employees.ParentUniqueName</Parent>
>> > <GroupExpressions>
>> >
>> > <GroupExpression>=Fields!Employees.UniqueName</GroupExpression>
>> > </GroupExpressions>
>> > </Grouping>
>> > </Details>
>> > <Header>
>> > <TableRows>
>> > <TableRow>
>> > <TableCells>
>> > <TableCell>
>> > <ReportItems>
>> > <Textbox Name="textbox1">
>> > <rd:DefaultName>textbox1</rd:DefaultName>
>> > <ZIndex>14</ZIndex>
>> > <Style>
>> > <PaddingLeft>2pt</PaddingLeft>
>> > <PaddingBottom>2pt</PaddingBottom>
>> > <PaddingRight>2pt</PaddingRight>
>> > <PaddingTop>2pt</PaddingTop>
>> > </Style>
>> > <CanGrow>true</CanGrow>
>> > <Value>Employees</Value>
>> > </Textbox>
>> > </ReportItems>
>> > </TableCell>
>> > <TableCell>
>> > <ReportItems>
>> > <Textbox Name="textbox4">
>> > <rd:DefaultName>textbox4</rd:DefaultName>
>> > <ZIndex>13</ZIndex>
>> > <Style>
>> > <PaddingLeft>2pt</PaddingLeft>
>> > <PaddingBottom>2pt</PaddingBottom>
>> > <PaddingRight>2pt</PaddingRight>|||Robert-
Fabulous post. Was wondering if you had any suggestions for using
parent-child dimensions in Report Builder...
(Of course, I'm talking about using a model which is generated on top of an
SSAS cube.) If I'm looking at a standard dimension, each level in the
hierarchy will be a separate attribute (such as Region and City), so it's
easy to just drop Region and City onto a Report Builder report and get the
nice nesting I want. However, with parent-child dimensions, each level isn't
a separate attribute... and since Report Builder doesn't render any
hierarchies in a dimension (whether it's a user-defined hierarchy or the
hierarchy built by the marking an attribute as the Parent), I can't figure
out a way to build a Report Builder report which would have a Region column
and a City column if both Region and City are part of the parent child
dimension. Any suggestions would be appreciated.
The reason we had to make it a parent-child dimension is because one measure
group can have facts at several levels... so the only way we could do this is
with a parent-child hierarchy as standard dimensions can only have data at
one grain per measure group. (Correct me if I'm wrong.)
Thanks for any suggestions.
"Robert Bruckner [MSFT]" wrote:
> I attached a sample report that shows how to do this.
> Notes:
> * in the graphical query designer you have to select a recursive hierarchy
> from the cube (such as Employee.Employees in the AdventureWorks DW cube).
> Based on the metadata, RS should automatically detect that this is a
> recursive parent-child hierarchy and there will be additional extended field
> properties available (such as .UniqueName and .ParentUniqueName)
> * add a grouping in the report. The grouping expression is based on
> =Fields!Employees.UniqueName and for the parent of the group set it to
> =Fields!Employees.ParentUniqueName
> * right now, you will need to have table columns that also reference the
> UniqueName and the ParentUniqueName in the report - but you can hide them so
> they are not visible. If you don't have these columns, the recursive
> hierarchy won't work correctly.
> -- Robert
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> "Raghu" <Raghu@.discussions.microsoft.com> wrote in message
> news:A3B4E2B3-B78D-4571-9D90-69EC03FD18E4@.microsoft.com...
> > I'm trying to use an OLAP cube as my data source (built using SSAS 2005)
> > The cube has a parent-child dimension and a fact table. I would like to
> > display the parent-child data in a report . Does anyone know how to build
> > an
> > MDX query that would give me the ID and the ParentID from the dimension to
> > build the parent-child grouping relationship in the report? The MDX
> > builder
> > does not let me access the ID field or the ParentID field. I always get
> > the
> > Name of the dimension.
> >
> > Also, if there's another way to do this, please let me know.
> >
> > Any help is greatly appreciated.
> >
> > Thanks
>
> ==========================================================> <?xml version="1.0" encoding="utf-8"?>
> <Report
> xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition"
> xmlns:rd="">http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
> <DataSources>
> <DataSource Name="DataSource1">
> <ConnectionProperties>
> <IntegratedSecurity>true</IntegratedSecurity>
> <ConnectString>Data Source=(local);Initial Catalog="Adventure Works
> DW"</ConnectString>
> <DataProvider>OLEDB-MD</DataProvider>
> </ConnectionProperties>
> <rd:DataSourceID>5aaa5577-4975-4616-a136-0b713dab6948</rd:DataSourceID>
> </DataSource>
> </DataSources>
> <BottomMargin>1in</BottomMargin>
> <RightMargin>1in</RightMargin>
> <rd:DrawGrid>true</rd:DrawGrid>
> <InteractiveWidth>8.5in</InteractiveWidth>
> <rd:SnapToGrid>true</rd:SnapToGrid>
> <Body>
> <ReportItems>
> <Table Name="table1">
> <Footer>
> <TableRows>
> <TableRow>
> <TableCells>
> <TableCell>
> <ReportItems>
> <Textbox Name="textbox7">
> <rd:DefaultName>textbox7</rd:DefaultName>
> <ZIndex>9</ZIndex>
> <Style>
> <PaddingLeft>2pt</PaddingLeft>
> <PaddingBottom>2pt</PaddingBottom>
> <PaddingRight>2pt</PaddingRight>
> <PaddingTop>2pt</PaddingTop>
> </Style>
> <CanGrow>true</CanGrow>
> <Value />
> </Textbox>
> </ReportItems>
> </TableCell>
> <TableCell>
> <ReportItems>
> <Textbox Name="textbox9">
> <rd:DefaultName>textbox9</rd:DefaultName>
> <ZIndex>8</ZIndex>
> <Style>
> <PaddingLeft>2pt</PaddingLeft>
> <PaddingBottom>2pt</PaddingBottom>
> <PaddingRight>2pt</PaddingRight>
> <PaddingTop>2pt</PaddingTop>
> </Style>
> <CanGrow>true</CanGrow>
> <Value />
> </Textbox>
> </ReportItems>
> </TableCell>
> <TableCell>
> <ReportItems>
> <Textbox Name="textbox8">
> <rd:DefaultName>textbox8</rd:DefaultName>
> <ZIndex>7</ZIndex>
> <Style>
> <PaddingLeft>2pt</PaddingLeft>
> <PaddingBottom>2pt</PaddingBottom>
> <PaddingRight>2pt</PaddingRight>
> <PaddingTop>2pt</PaddingTop>
> </Style>
> <CanGrow>true</CanGrow>
> <Value />
> </Textbox>
> </ReportItems>
> </TableCell>
> <TableCell>
> <ReportItems>
> <Textbox Name="textbox11">
> <rd:DefaultName>textbox11</rd:DefaultName>
> <ZIndex>6</ZIndex>
> <Style>
> <TextAlign>Center</TextAlign>
> <PaddingLeft>2pt</PaddingLeft>
> <PaddingBottom>2pt</PaddingBottom>
> <PaddingRight>2pt</PaddingRight>
> <PaddingTop>2pt</PaddingTop>
> </Style>
> <CanGrow>true</CanGrow>
> <Value />
> </Textbox>
> </ReportItems>
> </TableCell>
> <TableCell>
> <ReportItems>
> <Textbox Name="textbox13">
> <rd:DefaultName>textbox13</rd:DefaultName>
> <ZIndex>5</ZIndex>
> <Style>
> <PaddingLeft>2pt</PaddingLeft>
> <PaddingBottom>2pt</PaddingBottom>
> <PaddingRight>2pt</PaddingRight>
> <PaddingTop>2pt</PaddingTop>
> </Style>
> <CanGrow>true</CanGrow>
> <Value />
> </Textbox>
> </ReportItems>
> </TableCell>
> </TableCells>
> <Height>0.25in</Height>
> </TableRow>
> </TableRows>
> </Footer>
> <DataSetName>DataSet1</DataSetName>
> <Top>0.5in</Top>
> <Details>
> <TableRows>
> <TableRow>
> <TableCells>
> <TableCell>
> <ReportItems>
> <Textbox Name="Employees">
> <rd:DefaultName>Employees</rd:DefaultName>
> <ZIndex>4</ZIndex>
> <Style>
> <PaddingLeft>=2 + Level() * 8 &
> "pt"</PaddingLeft>
> <PaddingBottom>2pt</PaddingBottom>
> <PaddingRight>2pt</PaddingRight>
> <PaddingTop>2pt</PaddingTop>
> </Style>
> <CanGrow>true</CanGrow>
> <Value>=Fields!Employees.Value</Value>
> </Textbox>
> </ReportItems>
> </TableCell>
> <TableCell>
> <ReportItems>
> <Textbox Name="textbox10">
> <ZIndex>3</ZIndex>
> <Style>
> <PaddingLeft>2pt</PaddingLeft>
> <PaddingBottom>2pt</PaddingBottom>
> <PaddingRight>2pt</PaddingRight>
> <PaddingTop>2pt</PaddingTop>
> </Style>
> <CanGrow>true</CanGrow>
> <Value>=Fields!Employees.UniqueName</Value>
> </Textbox>
> </ReportItems>
> </TableCell>
> <TableCell>
> <ReportItems>
> <Textbox Name="textbox5">
> <rd:DefaultName>textbox5</rd:DefaultName>
> <ZIndex>2</ZIndex>
> <Style>
> <PaddingLeft>2pt</PaddingLeft>
> <PaddingBottom>2pt</PaddingBottom>
> <PaddingRight>2pt</PaddingRight>
> <PaddingTop>2pt</PaddingTop>
> </Style>
> <CanGrow>true</CanGrow>
> <Value>=Fields!Employees.ParentUniqueName</Value>
> </Textbox>
> </ReportItems>
> </TableCell>
> <TableCell>
> <ReportItems>
> <Textbox Name="Reseller_Sales_Amount">
> <rd:DefaultName>Reseller_Sales_Amount</rd:DefaultName>
> <ZIndex>1</ZIndex>
> <Style>
> <TextAlign>Center</TextAlign>
> <PaddingLeft>2pt</PaddingLeft>
> <PaddingBottom>2pt</PaddingBottom>
> <PaddingRight>2pt</PaddingRight>
> <PaddingTop>2pt</PaddingTop>
> </Style>
> <CanGrow>true</CanGrow>
> <Value>=Level()</Value>
> </Textbox>
> </ReportItems>
> </TableCell>
> <TableCell>
> <ReportItems>
> <Textbox Name="Reseller_Sales_Amount_1">
> <rd:DefaultName>Reseller_Sales_Amount_1</rd:DefaultName>
> <Style>
> <TextAlign>Right</TextAlign>
> <PaddingLeft>2pt</PaddingLeft>
> <PaddingBottom>2pt</PaddingBottom>
> <PaddingRight>2pt</PaddingRight>
> <PaddingTop>2pt</PaddingTop>
> </Style>
> <CanGrow>true</CanGrow>
> <Value>=Sum(Fields!Reseller_Sales_Amount.Value)</Value>
> </Textbox>
> </ReportItems>
> </TableCell>
> </TableCells>
> <Height>0.25in</Height>
> </TableRow>
> </TableRows>
> <Grouping Name="table1_Details_Group">
> <Parent>=Fields!Employees.ParentUniqueName</Parent>
> <GroupExpressions>
> <GroupExpression>=Fields!Employees.UniqueName</GroupExpression>
> </GroupExpressions>
> </Grouping>
> </Details>
> <Header>
> <TableRows>
> <TableRow>
> <TableCells>
> <TableCell>
> <ReportItems>
> <Textbox Name="textbox1">
> <rd:DefaultName>textbox1</rd:DefaultName>
> <ZIndex>14</ZIndex>
> <Style>
> <PaddingLeft>2pt</PaddingLeft>
> <PaddingBottom>2pt</PaddingBottom>
> <PaddingRight>2pt</PaddingRight>
> <PaddingTop>2pt</PaddingTop>
> </Style>
> <CanGrow>true</CanGrow>
> <Value>Employees</Value>
> </Textbox>
> </ReportItems>
> </TableCell>
> <TableCell>
> <ReportItems>
> <Textbox Name="textbox4">
> <rd:DefaultName>textbox4</rd:DefaultName>
> <ZIndex>13</ZIndex>
> <Style>
> <PaddingLeft>2pt</PaddingLeft>
> <PaddingBottom>2pt</PaddingBottom>
> <PaddingRight>2pt</PaddingRight>
> <PaddingTop>2pt</PaddingTop>
> </Style>
> <CanGrow>true</CanGrow>
> <Value />
> </Textbox>
> </ReportItems>
> </TableCell>
> <TableCell>
> <ReportItems>
> <Textbox Name="textbox2">
> <rd:DefaultName>textbox2</rd:DefaultName>
> <ZIndex>12</ZIndex>
> <Style>
> <PaddingLeft>2pt</PaddingLeft>
> <PaddingBottom>2pt</PaddingBottom>
> <PaddingRight>2pt</PaddingRight>
> <PaddingTop>2pt</PaddingTop>
> </Style>
> <CanGrow>true</CanGrow>