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

Friday, March 23, 2012

Median calculation

I want to calculate the MEDIAN time interval between the two date field. In an OLAP cube one of the dimension consists of the two date fields as well as Interval(days) field (calculated at the data source view). How to create a Measure in the OLAP cube to calculate the MEDIAN Interval?

MEDIAN( <<Set>>[, <<Numeric Expression>>])

Since I'm not sure of the details your dimension, here's an Adventure Works sample query, for the Median duration in days of a Promotion:

>>

With Member [Measures].[MedPromoDays] as

Median(existing [Promotion].[Promotion].[Promotion],

DateDiff("d", [Promotion].[Promotion].Properties("Start Date", TYPED),

[Promotion].[Promotion].Properties("End Date", TYPED)))

select {[Measures].[MedPromoDays]} on 0,

[Promotion].[Promotion Type].Members on 1

from [Adventure Works]

MedPromoDays
All Promotions 83.5
Discontinued Product 53
Excess Inventory 61
New Product 91
No Discount 1309
Seasonal Discount 30
Volume Discount 1095

>>

|||

And to slightly change Deepak's query to be more efficient:

With Member [Measures].[MedPromoDays] as

Median(existing [Promotion].[Promotion].[Promotion],

DateDiff("d", [Promotion].[Start Date].MemberValue,

[Promotion].[End Date].MemberValue))

select {[Measures].[MedPromoDays]} on 0,

[Promotion].[Promotion Type].Members on 1

from [Adventure Works]

Wednesday, March 21, 2012

Measures to columns in Excel

Dear anyone

I am transfering the information from the cube to Excel.

My wizard places all measures in the pivot table to one column. I am using Excel 2003.

I would like to place the measures to different columns to get a result which is easy to read and copy.

Could anyone advice me how this can be done ?

Thanks !

Matti

You just have to drag & drop the field "Data" from the rows to the columns.|||

Thanks Rmi

Your advice sounds simple, I expected the same.

The problem is that but my Add-button is inhibited when

trying to do that. Could this be caused by cube definitions ?

Matti

|||

If I try to use drag and drop, I get an error from Excel. Translation of error message is something like this: "The field You are transfering can't be placed in this area of the pivot table".

Matti

|||I don't think it comes from your cube. I am sorry if my answer seems a little too simple, but are you sure you drag & drop the field on the header of the columns (not the content of the table). In fact you can put numeric values in the content of table, but dimension attributes need to be in row headers or column headers or filter.|||

I want to summarize, that I can easily drag and drop all dimensions to either lines or to columns Measures I can only place to the same column.

Matti

|||Yes, of course, sorry I got lost... I just wanted you to drag and drop the field "data" which represents the Measures on the header of the column. And if it doesn't work, then I will let someone else help you because I don't have another idea...|||

Thanks for kind help Rèmi !

This is a question of the layout of the report and the form of the paper.

What I get is:

DimA1 DimA2

DimB1 MV1A1B1 MV1A2B1

MV2A1B1 MV2A2B1

DimB2 MV1A1B2 MV1A2B2

MV2A1B2 MV2A2B2

What I want to get:

DimA1 DimA2

DimB1 MV1A1B1 MV2A1B1 MV1A2B1 MV2A2B1

DimB2 MV1A1B2 MV2A1B2 MV1A2B2 MV2A2B2

.

.

.

Matti

measure's name can not be same in different cube?

BY using the SSAS ,I find much problem,can someboby help me.

The problem :

1,why measure in different cube can not have the same name?

2,where I can modify the partition's ID?

3,where is the profile?

1). Measures in different cubes can have same names. But measures in same cube in different measure groups cannot have same name

2) Why do you want to modify partition ID ? (it is possible, but I wonder why)

3) Start -> Programs -> Microsoft SQL Server 2005 -> Performance Tools -> SQL Server Profiler

|||

>2) Why do you want to modify partition ID ? (it is possible, but I wonder why)

BI Studio generates from AN_IMPORTANT_FIELD or AnImportantField the ID "An Important Field". It is total uncomfortable to have spaces in the IDs. Why BI Studio thoughts that it is wiseacre that knows better as the rest? Why it doesn't leave ID untouched or doesn't ask for ID of the new being created item?

It is possible in the AMO to spesify ID at the time of an item creation, but it isn't in BI Studio. What a pity!

I want and I suppose all developers want also to have IDs as variables names to have a pleasure at work with them und don't confront with daft ids generated by wiseacre BI studio.

Don't persuade us to work with names. The names are for businnes users, not for developers. Usually they are too lang and have to many spaces und other signes, that don't belongs to 26 low case chars of english alphabet.

Measures data disappeared suddendly

Hello every body,

I made a cube with SSAS, it worked well, I could show my data (measures and dimension) in the ssas-browser.

I made some modification because there was some trouble with a dimension, like I often did it already (I'm new on this product),

and now the cube compiles well again, I see my dimension correctly, but... the data of the measures disappeared ! They are now empty, and I do not see at all what is the matter?

But the fact tables are correctly full of data.

Thanks for any help

Check the calculations

tab of the cube and make sure it contains the "CALCULATE" command.

This is included by default, but if deleted will prevent the cube from

aggregating data from the leaf cells up to the rest of the cube.|||

Thank you very much!

Now it is working!! None of my collegs knew what to do.

Thanks!

sql

MeasureExpression Property - How to use

I have a cube with several MeasureGroups.

I want to provide a calculated measure "Average Sale Price" which is calculated as "Gross Revenue" / "Product Count".

Both the "Gross Revenue" and "Product Count" measures belonging to the same measure group ... "Royalty Statement". Ideally I would like the "Average Sale Price" measure also to belong to the "Royalty Statement" Measure Group also.

I am therefore trying to use a MeasureExpression calculation on a regular measure, as opposed to a Calculated Member to achieve the calculation. (or can someone advise how to make a Calculated Member appear within a specific Measure Group ?)


On the measure properties
- "AggregateFunction" is set to "Sum"
- "MeasureExpression" is set to "[Measures].[Gross Revenue] / [Measures].[Product Count]"

On deploying the cube I get ... "Error 1 Errors in the metadata manager. The 'Product Count' right operand of the measure expression of the 'Average Sale Price' measure cannot belong to the same measure group. "

Can I really not have a MeasureExpression with the numerator and denominator in the same Measure Group ?

I have futzed with things a bit including getting the cube to process by using a denominator from a different MeasureGroup, and playing with the Source object binding.

What am I missing ?

Thanks in Advance

Marcus

No. I do not think that you can use the same measure group in measure expressions. This is the new version of Lookup cube(MDX) in AS2005 with limited support for calculations except (*, /)

You can achive the same with a calculated member.

Regards

Thomas Ivarsson

|||

Marcus,

You can easily associate your calculated measure with any existing measure group. To do this, please follow these steps:

- Open your project in SQL Server Business Intelligence Development Studio & double click your cube

- In the Cube editor, go to the Calculations tab and double click your calculated member "Average Sale Price"

- In the toolbar, just right from the "Form View" and "Script View" toolbar buttons, click on the "Calculation Properties" toolbar button

- In the Calculation Properties dialog that comes up, select your calculated member "Average Sale Price" from the dropdown and set the associated measure group for it to be "Royalty Statement"

- Deploy the project and you are ready to go

Hope this helps,

Artur

|||

Thanks Artur, that helps.

If I do this, can I also assume that the Dimension Usage characteristics for that Measure Group now apply to the Calcuated Member ?

Marcus

|||

Unfortunately the answer is no. This is a common request from customers and is planned to be implemented in our next release. For Yukon, you could use the following work around: if you want to associate the new calculated member with specific dimensions, you could set the non-empty behavior for the calculated member to a measure from a measure group that intersects with those dimensions.

Hope this helps,

Artur

MeasureExpression Property - How to use

I have a cube with several MeasureGroups.

I want to provide a calculated measure "Average Sale Price" which is calculated as "Gross Revenue" / "Product Count".

Both the "Gross Revenue" and "Product Count" measures belonging to the same measure group ... "Royalty Statement". Ideally I would like the "Average Sale Price" measure also to belong to the "Royalty Statement" Measure Group also.

I am therefore trying to use a MeasureExpression calculation on a regular measure, as opposed to a Calculated Member to achieve the calculation. (or can someone advise how to make a Calculated Member appear within a specific Measure Group ?)


On the measure properties
- "AggregateFunction" is set to "Sum"
- "MeasureExpression" is set to "[Measures].[Gross Revenue] / [Measures].[Product Count]"

On deploying the cube I get ... "Error 1 Errors in the metadata manager. The 'Product Count' right operand of the measure expression of the 'Average Sale Price' measure cannot belong to the same measure group. "

Can I really not have a MeasureExpression with the numerator and denominator in the same Measure Group ?

I have futzed with things a bit including getting the cube to process by using a denominator from a different MeasureGroup, and playing with the Source object binding.

What am I missing ?

Thanks in Advance

Marcus

No. I do not think that you can use the same measure group in measure expressions. This is the new version of Lookup cube(MDX) in AS2005 with limited support for calculations except (*, /)

You can achive the same with a calculated member.

Regards

Thomas Ivarsson

|||

Marcus,

You can easily associate your calculated measure with any existing measure group. To do this, please follow these steps:

- Open your project in SQL Server Business Intelligence Development Studio & double click your cube

- In the Cube editor, go to the Calculations tab and double click your calculated member "Average Sale Price"

- In the toolbar, just right from the "Form View" and "Script View" toolbar buttons, click on the "Calculation Properties" toolbar button

- In the Calculation Properties dialog that comes up, select your calculated member "Average Sale Price" from the dropdown and set the associated measure group for it to be "Royalty Statement"

- Deploy the project and you are ready to go

Hope this helps,

Artur

|||

Thanks Artur, that helps.

If I do this, can I also assume that the Dimension Usage characteristics for that Measure Group now apply to the Calcuated Member ?

Marcus

|||

Unfortunately the answer is no. This is a common request from customers and is planned to be implemented in our next release. For Yukon, you could use the following work around: if you want to associate the new calculated member with specific dimensions, you could set the non-empty behavior for the calculated member to a measure from a measure group that intersects with those dimensions.

Hope this helps,

Artur

Measure with "Distinct Count" Aggregate Function and Null value

I Have a cube with many measures. One of them use as "Aggregate
Function" the function "Distinct Count". But some records of fact table
has null value in the field of this measure. In SQL Server, when I
execute a "SELECT COUNT (DISTINCT field)" command, it eliminates the
Null value, as showed in the next exemple:
Table X
field A
1122
2345
4567
1122
1122
2345
null
null
When a execute the command:
SELECT COUNT (DISTINCT A) FROM X
I recieve "3" as result.
But when I create a measure over the field A in a cube and I choose the
aggregate funtion "Distinct Count", I recieve "4" as result. I think
that Analysis Services is considering "null" as one of distinct values
of the field A, but I dont want that, because it makes no sense for me.
Is there a way to eliminate the null value in Analysis Services, to show
"3" as the result in the same way I receive in SQL Server?
Thanks,
Paulo
*** Sent via Developersdex http://www.codecomments.com ***
I am new to SQL server, but experieced in Oracle.
My top of mind test would be:
select count(distinct *) from x => 4
select count(distinct a) from x => 3
It's standard SQL behaviour, I think.
pls verify, tks
|||When a execute the command "select count(distinct *) from x" , I recieve
"4" as result and when a execute the command "select count(distinct a)
from x", I recieve "3" as result.
But my problem is not with SQL Server. My problem is in Analysis
Services. I created a measure over the field "a", with the aggregate
function "Distinct Count". But the result in Analysis Services is "4"
and not "3", as I expected.
Do you have a clue?
Thanks,
Paulo
*** Sent via Developersdex http://www.codecomments.com ***
|||try to create a new cube (copy/paste the current one)
then create a view on the database like:
select * from mytable where mycolumntodcount IS NOT NULL
use this view in the new cube.
this cube will contain only the dcount measure and the null values are
ignored.
"Paulo Andre Ortega Ribeiro" <paulo.andre.66@.terra.com.br> wrote in message
news:ehCLkEZAGHA.2272@.TK2MSFTNGP11.phx.gbl...
> When a execute the command "select count(distinct *) from x" , I recieve
> "4" as result and when a execute the command "select count(distinct a)
> from x", I recieve "3" as result.
> But my problem is not with SQL Server. My problem is in Analysis
> Services. I created a measure over the field "a", with the aggregate
> function "Distinct Count". But the result in Analysis Services is "4"
> and not "3", as I expected.
> Do you have a clue?
> Thanks,
> Paulo
>
> *** Sent via Developersdex http://www.codecomments.com ***
|||I tried this solution and It works. But I dont want to create a new
cube. That will be my last option. Is not possible to ignore the null
vules with "distinct count" as the aggregate function? Is not there a
propriety that I can configure?
Thanks,
Paulo
*** Sent via Developersdex http://www.codecomments.com ***
|||the only other option I can propose is:
add a dimension in the cube, add a column in the fact table called "ToCount"
which contains a Y/N or 0/1 value linked to this new dimension.
case when MyColumn is null then 'N' else 'Y' end as ToCount
hide the dimension.
Rename the dcount measure to HiddenDcount, hide this measure
create a calculated measure which is:
(measures.HiddenDCount, MyDummyDimension.&[Y])
this ignore the null values.
"Paulo Andre Ortega Ribeiro" <paulo.andre.66@.terra.com.br> wrote in message
news:u9ciH0kAGHA.2040@.TK2MSFTNGP14.phx.gbl...
> I tried this solution and It works. But I dont want to create a new
> cube. That will be my last option. Is not possible to ignore the null
> vules with "distinct count" as the aggregate function? Is not there a
> propriety that I can configure?
> Thanks,
> Paulo
>
> *** Sent via Developersdex http://www.codecomments.com ***

Measure with "Distinct Count" Aggregate Function and Null value

I Have a cube with many measures. One of them use as "Aggregate
Function" the function "Distinct Count". But some records of fact table
has null value in the field of this measure. In SQL Server, when I
execute a "SELECT COUNT (DISTINCT field)" command, it eliminates the
Null value, as showed in the next exemple:
Table X
field A
1122
2345
4567
1122
1122
2345
null
null
When a execute the command:
SELECT COUNT (DISTINCT A) FROM X
I recieve "3" as result.
But when I create a measure over the field A in a cube and I choose the
aggregate funtion "Distinct Count", I recieve "4" as result. I think
that Analysis Services is considering "null" as one of distinct values
of the field A, but I dont want that, because it makes no sense for me.
Is there a way to eliminate the null value in Analysis Services, to show
"3" as the result in the same way I receive in SQL Server?
Thanks,
Paulo
*** Sent via Developersdex http://www.codecomments.com ***I am new to SQL server, but experieced in Oracle.
My top of mind test would be:
select count(distinct *) from x => 4
select count(distinct a) from x => 3
It's standard SQL behaviour, I think.
pls verify, tks|||When a execute the command "select count(distinct *) from x" , I recieve
"4" as result and when a execute the command "select count(distinct a)
from x", I recieve "3" as result.
But my problem is not with SQL Server. My problem is in Analysis
Services. I created a measure over the field "a", with the aggregate
function "Distinct Count". But the result in Analysis Services is "4"
and not "3", as I expected.
Do you have a clue?
Thanks,
Paulo
*** Sent via Developersdex http://www.codecomments.com ***|||try to create a new cube (copy/paste the current one)
then create a view on the database like:
select * from mytable where mycolumntodcount IS NOT NULL
use this view in the new cube.
this cube will contain only the dcount measure and the null values are
ignored.
"Paulo Andre Ortega Ribeiro" <paulo.andre.66@.terra.com.br> wrote in message
news:ehCLkEZAGHA.2272@.TK2MSFTNGP11.phx.gbl...
> When a execute the command "select count(distinct *) from x" , I recieve
> "4" as result and when a execute the command "select count(distinct a)
> from x", I recieve "3" as result.
> But my problem is not with SQL Server. My problem is in Analysis
> Services. I created a measure over the field "a", with the aggregate
> function "Distinct Count". But the result in Analysis Services is "4"
> and not "3", as I expected.
> Do you have a clue?
> Thanks,
> Paulo
>
> *** Sent via Developersdex http://www.codecomments.com ***|||I tried this solution and It works. But I dont want to create a new
cube. That will be my last option. Is not possible to ignore the null
vules with "distinct count" as the aggregate function? Is not there a
propriety that I can configure?
Thanks,
Paulo
*** Sent via Developersdex http://www.codecomments.com ***|||the only other option I can propose is:
add a dimension in the cube, add a column in the fact table called "ToCount"
which contains a Y/N or 0/1 value linked to this new dimension.
case when MyColumn is null then 'N' else 'Y' end as ToCount
hide the dimension.
Rename the dcount measure to HiddenDcount, hide this measure
create a calculated measure which is:
(measures.HiddenDCount, MyDummyDimension.&[Y])
this ignore the null values.
"Paulo Andre Ortega Ribeiro" <paulo.andre.66@.terra.com.br> wrote in message
news:u9ciH0kAGHA.2040@.TK2MSFTNGP14.phx.gbl...
> I tried this solution and It works. But I dont want to create a new
> cube. That will be my last option. Is not possible to ignore the null
> vules with "distinct count" as the aggregate function? Is not there a
> propriety that I can configure?
> Thanks,
> Paulo
>
> *** Sent via Developersdex http://www.codecomments.com ***

Monday, March 19, 2012

Measure group related question

I have a cube with two fact tables, two measure groups. I also created few calculated measures.

On client side I see two measure groups and below the calculated measure.

Is there any way I can show that calculated measure in one of the measure group. It's easy for end user to see number measure and % measure both next to each other.

I hope this can be possible using MDX some how update mdx for measure group or some thing...

Thank you - Ashok

Ashok,

You can easily associate your calculated measure with any existing measure group. To do this, please follow these steps:

- Open your project in SQL Server Business Intelligence Development Studio & double click your cube

- In the Cube editor, go to the Calculations tab and double click your calculated member "Average Sale Price"

- In the toolbar, just right from the "Form View" and "Script View" toolbar buttons, click on the "Calculation Properties" toolbar button

- In the Calculation Properties dialog that comes up, select your calculated member "Average Sale Price" from the dropdown and set the associated measure group for it to be "Royalty Statement"

- Deploy the project and you are ready to go

Hope this helps,

Artur

|||

You are the man Thanks. Is there any way to move a measure from one group to another. I know If I change underline Table/View it can be done but is there any way in cube design time I can move measure from one group to another.

-Ashok

|||

Ashok, moving a measure from one measure group to another is not currently supported in AS 2005.

--Artur

Measure data type from UDM to ADOMD

Ok, so here is my dilemma.

I need to get the data type of a measure in ADOMD.NET.

I have a SSAS project which deploys a cube. The measure is defined in this project file as having a FormatString of "Currency" (this is in the "Basic" section of the measure properties in Visual Studio).

I have tried to use the format_string property by using "

Code Snippet

CELL PROPERTIES FORMAT_STRING

", but this still returns "#, #" as the format string.

How do I get the data type of the measure?

Thanks

hello,

MDSCHEMA_MEASURES schema rowset has DATA_TYPE column which contains measure's the data type.

In Adomd.net you can get to this information in 2 ways: either execute schema rowset request directly (with connection.GetSchemaDataSet method), or via metadata objects. Measure object has .Properties collection, and you can find the DATA_TYPE property in it. So Measure.Properties["DATA_TYPE"].Value should contain the data type of the measure. (i think you can compare the values with System.Data.OleDb.OleDbDataType enum values), for example i can test if measure's data type is returned as currentcy with something like this:

(UInt16)measure.Properties["DATA_TYPE"].Value == (UInt16)System.Data.OleDb.OleDbType.Currency

You should be able to get to Measure object either from .Measures colleciton exposed on cube, or by

cube.GetSchemaObject(SchemaObjectType.ObjectTypeMeasure, <unique name of the measure>) as Measure

hope this helps,

Measure data disappears

help!! can someone please help me. I built a simple cube with three
tables in. When i clicked on the data tab within the cube editor i can
see my cube data. When i clicked on save the measure data disappear and
just my dimensions stayed there and i could drill down okay but no
measure dataI had a similar problem, and the issue ended up being that I had, by mistake
,
deleted the "Calculate;" command in the cube's script when I was created a
Named Set. Once I added that back all my measures started calculating again
.
I hope helps...
"shawrie" wrote:

> help!! can someone please help me. I built a simple cube with three
> tables in. When i clicked on the data tab within the cube editor i can
> see my cube data. When i clicked on save the measure data disappear and
> just my dimensions stayed there and i could drill down okay but no
> measure data
>

MdxScript error when processing a cube

Im getting an error while processing my cube:

The level '<level>' object was not found in the cube when the string, <fact>, was parsed.

Do you guys know why this could be happening?

Thanks,

-E

Maybe an error in your MDX statments.

Check the MDX script you have in Calculations Tab of SSAS...

I hope helped you!

regards!

MdxScript error using role security

The following error is displayed when trying to open a cube...

"An error occurred in the application: MdxScript(Quota Sales)(30,24) Then dimension '[Sales]' was not found in the cube when string, [Sales], was parsed"

I am using role security and am trying to hide a base measure [Measures].[Sales] along with two calculated measures that use the base measure. The cube does not have a [Sales] dimension.

I am using the Dimension Data tab within the role designer and denying all measures then selecting only the ones I want to appear in the cube. Those are written automatically into the "allowed member set" panel on the advanced tab. I have also tried allowing all members and then unchecking the Sales measure and specifying the [Measures].[Sales] measure and the two calculated measures in the "denied member set" panel on the advanced tab. I get the error either way.

I am using SSAS 2k5 and I receive the error when trying to open the cube using the ProClarity Professional client, although I don't think ProClarity is the issue.

Thanks in advance for any help.
Jay Hotchkiss

I've heard of some problems with security and MDX Scripts, although I can't find the relevant link at the moment...

...but, can you post the section of your MDX Script that's causing the error, ie everything around line 30? Is it by any chance something (like a calculated member definition, or named set) which refers to the Sales measure as
[Sales]
rather than using the full unique name of
[Measures].[Sales]
? If so, can you try using the full unique name in the MDX Script and seeing if you still get the same error?

Chris

|||

So that's what MDXScript is referring to, the calculated measure script! Yes, I have a number of calculations (time intellligence stuff) that are checking the Sales measure for NonEmpty behavior. I missed those. I'll do some work on the script and reply back here with the results. I think I can check another measure for NonEmpty instead of having to list all those calculated measure in the "denied set" for the role's security. Thanks very much. Jay

|||Thanks Christopher, I had a few calculated sets that were referring to my Sales measure. I appreciate the help. Jay|||For each dimension, you can set the MdxMissingMemberMode property in SSAS 2005. Perhaps this could solve your problem.

MdxScript error using role security

The following error is displayed when trying to open a cube...

"An error occurred in the application: MdxScript(Quota Sales)(30,24) Then dimension '[Sales]' was not found in the cube when string, [Sales], was parsed"

I am using role security and am trying to hide a base measure [Measures].[Sales] along with two calculated measures that use the base measure. The cube does not have a [Sales] dimension.

I am using the Dimension Data tab within the role designer and denying all measures then selecting only the ones I want to appear in the cube. Those are written automatically into the "allowed member set" panel on the advanced tab. I have also tried allowing all members and then unchecking the Sales measure and specifying the [Measures].[Sales] measure and the two calculated measures in the "denied member set" panel on the advanced tab. I get the error either way.

I am using SSAS 2k5 and I receive the error when trying to open the cube using the ProClarity Professional client, although I don't think ProClarity is the issue.

Thanks in advance for any help.
Jay Hotchkiss

I've heard of some problems with security and MDX Scripts, although I can't find the relevant link at the moment...

...but, can you post the section of your MDX Script that's causing the error, ie everything around line 30? Is it by any chance something (like a calculated member definition, or named set) which refers to the Sales measure as
[Sales]
rather than using the full unique name of
[Measures].[Sales]
? If so, can you try using the full unique name in the MDX Script and seeing if you still get the same error?

Chris

|||

So that's what MDXScript is referring to, the calculated measure script! Yes, I have a number of calculations (time intellligence stuff) that are checking the Sales measure for NonEmpty behavior. I missed those. I'll do some work on the script and reply back here with the results. I think I can check another measure for NonEmpty instead of having to list all those calculated measure in the "denied set" for the role's security. Thanks very much. Jay

|||Thanks Christopher, I had a few calculated sets that were referring to my Sales measure. I appreciate the help. Jay|||For each dimension, you can set the MdxMissingMemberMode property in SSAS 2005. Perhaps this could solve your problem.

Monday, March 12, 2012

MDX to work only on leaf cells

Hello!

Again I am unable to solve a rather simple looking problem with MDX. My cube looks something like this:

Group Detail MesA MesB MesC

a 1 300 50 37 (300 * 50 / 400)

a 2 300 100 75 (300 * 100 / 400)

a 3 300 250 187 (300 * 250 / 400)

a Total 300 400 133 (300 * 400 / 900)

... more groups (b, c, d ...) of this style ...

Grand Total 700 900 <NUM>

As you already noticed, MesA is a Measure that existeds on group grain only, so the value is the same for every entry on detail. My first goal is to distribute the MesA according to what I found on MesB (with rounding or such, a detail we can leave out here). I managed to do that as a computed column C (using very kind help from here) with the following MDX:

[Measures].[MesA] * [Measures].[MesB] / ([Dim].[Hie].CurrentMember.Parent, [Measures].[MesB])

This MDX works as intended for a leaf, but when it hits the first subtotal, it calculates the value using the totals from the grand total line. On the grand total line, it fails completly because there is no parent available anymore.

How can I avoid that? I tried my luck using the ISLEAF function, but I cannot get that working. I was able to produce the correct number (300) for the orange field using another bit of MDX:

([Measures].[MesC], [Dim].[Hie].Members) = Sum(Existing [Dim].[Hie].[Detail].Members, [Measures].[MesC])

That works on the first impression, but the little I understand of MDX makes me wonder what I am doing there at all. It only works on first impression, because in my example, if you use your Frontend Cube Browser to hide that row a-2, the total for the orange field should go down to 225, the sum of the remaining visible. It does not, as I "enforce" the value stored at this cell fields instead of relying on the cube to simple total them up.

So... what can I do? Thanks in advance!

Ralf

(Sorry for the weird font sizes in this text. I do not know why, but I cannot get the upper and lower half to show the same size no matter what I try. Please excuse that!)

Hi Ralf,

Since you want MesC to roll up like a regular cube measure, one approach would be to initially define MesC as a "sum" measure on the same measure group as MesB (you can use the same source field, if you wish). Then add a leaf-level calculation to the cube MDX script, using your "distribution" MDX formula on the right side:

([Measures].[MesC], Leaves([Dim])) =

[Measures].[MesA] * [Measures].[MesB] / ([Dim].[Hie].CurrentMember.Parent, [Measures].[MesB])

|||

Deepak,

thanks for the tip with the Leaves() set, it was very helpful to get my solution closer to where I need to go to, but...

Are any strange behaviours known for the Grand Total result known when using own calculations? I am getting the strangest results here.

I wonder if there is a good way to send Table Create scripts and Project Files in case someone wants to reproduce that - I am (almost) sure this is no error I am causing anymore, but a real bug in the analysis engine (although... hm... could I be the first to spot such an issue? Unlikely...)

I reduced my real project to the very smallest version for this example.

I use 4 Tables, 2 of those form a dimension with one hierarchie of 2 levels (2 items a and b on level 1 in one table, and 4 items a1,a2,b1,b2 on level 2 in the other), a 3rd table is another simple dimension (with only 2 items x and y on the top row) and finally the 4th is the measure table, connected to the finest grain of of the hierarchy dimension and the "other" dimension. The measure is a simple "sum up" integer, the fact table has 8 rows (4 x 2). Nothing in that setup that should raise any concern, everything totally straight forward. No properties of the dimensions or the measures were tuned or changed or... everything just as the wizards do create when you click through them.

The cube script has only the CALCULATE order followed by one custom line ([Measures].[Value], Leaves()) = 1... that is all.

After I set it up, it looks this way:

x y Grand Total

a a1 1 1 2

a2 1 1 2

Total 2 2 4

b b1 1 1 2

b2 1 1 2

Total 2 2 4

Grand Total 4 4 8

That is all, looks very easy and logical and ... ok, now hide a2 for example, or b1 or so... my Grand total row then changes to "102 - 502 - 902" or "202 - 602 - 804", depending which item you hide. If you unhide it again, everything works perfectly fine again. I want to add that the subtotal line for a or b does change to " 1 - 1 - 2" as expected. Subtotals is fine, only Grand total is wrong.

I think I can explain the numbers, at least their amount: Say I hide element a2. I know that element a1 has a value of 100 in the SQL table before overriding it with a "number one" in my script, therefore the grand total is calculated out of 100 (a1) + 1 (b1) + 1 (b2). Again, the value for a1 and the subtotal for a is correct, both display as 1. But when the grand total is calculated, the a section is not changed by my "set to 1" script.

Can anyone make sense of that? As I said, if someone wants to try it I will work on a way to either post create scripts or whatever needed to solve that.

MDX to locate data on a higher aggregation from a lower aggregation

I think I have a strange problem with a cube. The problem does come from the source data provider, but since there are no means to change that, I have to live with it and make the best of it.

Let me try to describe my situation: I gather data on two levels, two different grades of aggregation (for me: Groups and individual lines). On the higher level, I see an exact amount of time (<-my target), on the finer one I only have a sum of my target value and another time span. I also have counts of members on each level.

What I need to do is "split up" the sum value I have on the fine grain level according to distribution on the higher granularity level.

Does MDX provide a way to "look up" one aggregation level from a cell and use that value as a base for calculation? what would be the typical commands to step up along one aggregation line and request a value from there?

This is a more detailed explanation of the situation in case you are interested:

I have two measures on a group level, like this:

Group 1 50 (a) 1000 (b)

Group 2 some numbers as well

The 50 (a) means 50 seconds average worktime that happened by 1000 (b) jobs that were handled in the group.

Each group consists of 2 to 5 lines. For each line I also have a counting of jobs and a time, but this time is a total time, consisting of a waiting period and the worktime, like this:

Group 1

Line 1 80 750

Line 2 120 250

So, what that means is Group 1 handled 1000 jobs with 50 seconds average worktime, and that resulted out of 750 jobs handled in line 1 with an average (waiting + working time) of 80 seconds and 250 jobs that had 120 seconds work and wait time.

What I need to do is find out how long the work time was in each line, how the 80 seconds distributes between work and wait time. The only way to do that is to estimate the the waiting time in both lines is equal (in my real project it really is, or I do estimate it to be equal as there is not reason not to think so)

If you resolve this little riddle, you find that Line 1 has a waiting of 40 and work of 40, and Line 2 is waiting 40 as well but working is 120.

Hi Ralf_From_Europe:

Perhaps I'm simplifying this too much. If I am simplifying too much please correct me and I can look at the problem again. I think you can get the value you want by using the .PARENT function. You can reference the <dim>.<hierarchy>.CURRENTMEMBER.PARENT and get the value from the group level for your calculation. To illustrate I included an MDX query in this reply which references the CurrentMember.Parent sales value, shows the value, and uses it in a calculation. The sample works against the AdventureWorks DW sample from Microsoft.

Hope this helps.

PaulG

WITH MEMBER Measures.ProductParentSales AS
'
([Product].[Product Categories].CurrentMember.Parent, [Measures].[Internet Sales Amount])
'

MEMBER Measures.MyNewCalc AS
'
Measures.ProductParentSales/[Measures].[Internet Sales Amount]
', FORMAT_STRING = "#,0.00"

SELECT
{[Measures].[Internet Sales Amount], Measures.ProductParentSales, Measures.MyNewCalc} ON COLUMNS,
{[Product].[Product Categories].[Subcategory].[Bottles and Cages]
,[Product].[Product Categories].[Subcategory].[Bottles and Cages].Children
,[Product].[Product Categories].[Subcategory].[Helmets]
,[Product].[Product Categories].[Subcategory].[Helmets].Children} ON ROWS
FROM [Adventure Works]
WHERE ([Date].[Calendar].[Calendar Year].&[2003])

|||

"..you find that Line 1 has a waiting of 40 and work of 40, and Line 2 is waiting 40 as well but working is 120". Shouldn't it be 80, not 120?

Anyway, if you look at the Adventure Works MDX Calculation Script section for [Measures].[Sales Amount Quota], you'll find allocations like:

/*-- Allocate equally to months in FY 2002 --*/

Scope

(

[Date].[Fiscal Year].&[2002],

[Date].[Fiscal].[Month].Members

);

This = [Date].[Fiscal].CurrentMember.Parent / 3;

End Scope;

The Sales Targets Measure Group relates to Date at the Calendar Quarter granularity, so monthly [Measures].[Sales Amount Quota] aren't directly loaded from fact data. Instead, they are allocated - is this along the lines of what you want to do?

|||

Thanks both of you for your responses. I think I do understand a bit better now, I think I understand what the MDX parts in each answer is trying to do, but... it turns out I do not know how to "use" MDX in my case, I do not know where to "put it" in my SSAS project. There is measured columns, unary operators, semiadditive calculations and finally custom rollups. I think I need to do a lot of reading in the "advanced design" chapters of my books.

It seems I left out a crucial detail in my first description as well, the data on the two different levels is in different tables and therefore in different measuregroups. I hope that does not mean this makes it impossible. The book I try to learn from does work with adventure works as well and uses several measure groups at once, so I dare say it is possible.

But if I may, let me take out the first step of what I need to and see if someone can help me with it. This is not really different from the original question, it is only the very first step to calculate an intermediate result needed later to solve the "real wanted" value. Say my cube looks like this:

Group Line Counter Value

G1 L1 750 80 750x 80=60,000

G1 L2 250 120 250x120=30,000

G1Total 1000 200 90,000 / 1,000 = 90

The 200 marked in red is just summed up, which is wrong. The correct calculation is shown on the right, and the result is 90. In words you would say: For all children (L1, L2) of a Group (G1) sum up all the products of counter x value and divide by the sum of counter.

Now: Can that be put into MDX? And if it can, where does it have to be "installed" into the cube? I would go with custom rollup, which requires me to put the MDX into a cell of the table the dimension is based on, correct?

I'd really appreciate any hint or website or book recommendation! Thanks in advance.

Ralf

P.S. Deepak:You are of course absolutly right, I wrote down the result wrong. Thanks for pointing it out!

|||

Assuming that you have a dimension like [DimGroupLine], with [Line] attribute rolling upto [Group] attribute, you could add such a calculation statement to your cube MDX script:

([Measures].[Value], [DimGroupLine].[Group].Members)

= Sum(Existing [DimGroupLine].[Line].[Line].Members,

[Measures].[Counter] * [Measures].[Value]) /

[Measures].[Counter];

MDX to consolidate dates with measures by columns

I have a cube in SQL Server Analysis Services 2005 that has a structure like:

Measures:
Number of Tickets ([Measures].[Number of Tickets])

Dimensions:
Submitted Date ([Submit Date].[Date].[Date])
Submitted By ([Submit By].[Name].[Name])
Assigned Date ([Assigned Date].[Date].[Date])
Assigned To ([Assign To].[Name].[Name])
Resolved Date ([Resolved Date].[Date].[Date])
Resolved By ([Resolved By].[Name].[Name])
....
I would like to have returned a result set that cosolidates the dates with the number of tickets for each (or similarly, consolidates the people with the number of tickets for each). I need a set of all dates back, with the number of tickets aliased appropriately, so that I end up with something similar to the following:

Date # Tickets Submitted # Tickets Assigned # Tickets Resolved
April 1, 2007 14 27 11

April 2, 2007 11 4 null

April 3, 2007 null null 5
... etc.

What is the MDX to do this? I know how I would do it in t-sql, but unfortunately I'm not very proficient in mdx yet. I have tried using LinkMember and can get a single set of dates, but still don't know how to get the different ticket counts for each.

You might be able to figure something out with LinkMember, but it could get messy.

Have you considered changing your structure and setting up a couple of common dimensions instead? This should make a lot of different analysis a lot easier.

Measures:

SubmittedCount, AssignedCount, ResovledCount

Dimensions:

Date

Person

Or even something like

Measures:

ActivityCount

Dimensions:

Date

Person

Activity (Submitted, Resolved, Assigned)

|||

Hi Patty,

as Darren said one possibility is to change the structure of your measuregroup. If you are not able to do so you could try the following (SLOWER!!!) MDX.

If you use the same Date Dimension for all your Dates (-> Same Keys) you can use Filter or VBA to calculate your measures. I tried this in Adventureworks and for me the VBA was faster.

Here The MDX I used in Adventure Works DW:

Code Snippet

WITH MEMBER Measures.[Orders Delivered]

--AS ([Measures].[Order Count], ROOT([Date]), FILTER([Delivery Date].[Date].[Date].MEMBERS, [Delivery Date].[Date].MEMBER_KEY = [Date].[Date].CURRENTMEMBER.MEMBER_KEY).Item(0))

AS ([Measures].[Order Count], ROOT([Date]), StrToMember(VBA!CSTR("[Delivery Date].[Date].&[" + [Date].[Date].CURRENTMEMBER.MEMBER_KEY +"]")))

SELECT

{[Measures].[Order Count],Measures.[Orders Delivered] } ON COLUMNS,

{[Date].[Date].[Date].MEMBERS} ON ROWS

FROM [Adventure Works]

As u see I use the Key Of the Current Date to generate the UNIQUE_NAME in the other date dimension with vba. You should be able to replace Date with Submitted Date and Delivery Date with Assigned Date.

Hope this helps

Markus

MDX Syntax equivalent of SQL (NOT IN) Clause

I have a cube that I'm trying to separate into 2 distinct populations. After filtering on several combinations of dimensions, I get a set of unique people. I have the MDX syntax for this and it works well. However, I then want to turn around and get all of the other people not selected in the first group.

I can't merely take the "not" dimensions of the first group because I have both one-to-one and one-to-many dimensions and doing that will double count a lot of them. Oh yea, I've got a distinct count member hanging around that is needed.

In sql, its very rudimentry but using the "where x not in (select y from tablename .... )" will get the all the others not in the first group.

Any suggestions on getting the equivalent statement in MDX built?

Thanks! jmac

Hi,

I think you should be able to accomplish what you're trying to do using the 'Except' function. Google has lot's of examples of it..

C
|||I'll take a look. Not sure how to get both results into two sets for comparison.|||If you have some crossjoining to get to the set of members you are interested in, you might also need to use the Extract() function in combination with Except() to get just the members from one attribute.

MDX Syntax equivalent of SQL (NOT IN) Clause

I have a cube that I'm trying to separate into 2 distinct populations. After filtering on several combinations of dimensions, I get a set of unique people. I have the MDX syntax for this and it works well. However, I then want to turn around and get all of the other people not selected in the first group.

I can't merely take the "not" dimensions of the first group because I have both one-to-one and one-to-many dimensions and doing that will double count a lot of them. Oh yea, I've got a distinct count member hanging around that is needed.

In sql, its very rudimentry but using the "where x not in (select y from tablename .... )" will get the all the others not in the first group.

Any suggestions on getting the equivalent statement in MDX built?

Thanks! jmac

Hi,

I think you should be able to accomplish what you're trying to do using the 'Except' function. Google has lot's of examples of it..

C
|||I'll take a look. Not sure how to get both results into two sets for comparison.|||If you have some crossjoining to get to the set of members you are interested in, you might also need to use the Extract() function in combination with Except() to get just the members from one attribute.

MDX statement using Parameters as Calendar

Hello People,
I'm developing reports using SQL2005 and Reporting Service 2005 where I'm
using MDX to extract the information from the cube, but now I need to get a
range of data as a parameter, but using the Calendar date picker from
Reporting server, do you know if is it possible ?
Thanks,
ElvisHi Elvis,
This issue was discussed a couple of months back (June CTP time-frame) in
the SQL Server 2005 Beta newsgroup, but unfortunately I can no longer locate
it. Anyway, what I recall is that I had to resort to using the old OLE DB for
OLAP Provider (which worked with MDX in RS 2000), because in that case the
MDX query is dynamically built as an expression; and the data type of date
parameters can then be set to DateTime, which will enable the Calendar date
picker. Of course, in that case, the expression has to transform the returned
date string to an appropriate MDX Date Dimension member name.
"elvispires" wrote:
> Hello People,
> I'm developing reports using SQL2005 and Reporting Service 2005 where I'm
> using MDX to extract the information from the cube, but now I need to get a
> range of data as a parameter, but using the Calendar date picker from
> Reporting server, do you know if is it possible ?
> Thanks,
> Elvis
>
>|||hi,
do you have an example of dynamically built mdx ? Becaus i also have that
problem.
with
member [month_list].[jan-sept] AS 'sum([month_list].[All
month_list].[January]:[Month_list].[All month_list].[September])'
the last [September] is supposed to be tha name of the current month
Thanks!
"Deepak" wrote:
> Hi Elvis,
> This issue was discussed a couple of months back (June CTP time-frame) in
> the SQL Server 2005 Beta newsgroup, but unfortunately I can no longer locate
> it. Anyway, what I recall is that I had to resort to using the old OLE DB for
> OLAP Provider (which worked with MDX in RS 2000), because in that case the
> MDX query is dynamically built as an expression; and the data type of date
> parameters can then be set to DateTime, which will enable the Calendar date
> picker. Of course, in that case, the expression has to transform the returned
> date string to an appropriate MDX Date Dimension member name.
> "elvispires" wrote:
> > Hello People,
> >
> > I'm developing reports using SQL2005 and Reporting Service 2005 where I'm
> > using MDX to extract the information from the cube, but now I need to get a
> > range of data as a parameter, but using the Calendar date picker from
> > Reporting server, do you know if is it possible ?
> >
> > Thanks,
> > Elvis
> >
> >
> >
> >