Showing posts with label below. Show all posts
Showing posts with label below. Show all posts

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

MDX-why the null result is missing?

Hi,friends, this is a newbie quetion about MDX.

I just write the MDX below:

select KPIValue("ADTD")on rows, {[Time].[TimeLevel].[Year].&[2007] } on columns from [TargetCube] where [Agent].[AgentMember].&[2]

And this return the result very well:

2007

ADTD 128

Then I change the MDX to this:

select KPIValue("ADTD")on rows, {[Time].[TimeLevel].[Year].&[2007],[Time].[TimeLevel].[Year].&[2008]} on columns from [TargetCube] where [Agent].[AgentMember].&[2]

And this return the same result:

2007

ADTD 128

It's very strange to me. Because there is no 2008's record in the Cube, I think the result ought to be :

2007 2008

ADTD 128 0

But why the result just makes the 2008's column Missing?

Thanks!

What is the MDX formula for KPIValue("ADTD"); and can you reproduce this problem with a KPI query in Adventure Works?|||

the MDX formula for KPIvalue("ADTD") is just refer to an Measure which Count the records of the facttable. I think this is not the answer. You could reproduce this problem with a KPI query in Adventrue Works.

And not only the KPI query, but every MDX query is like this. It looks like it's a common law of the MDX. You could have a simple test like this:

select ([Measures].Angel) on rows, {[Time].[TimeLevel].[Year].&[2008]} on columns from [Cube] where [Agent].[AgentLevel].&[2]

Because there is no 2008's records in the facttable, and you will get the result like this:

A

not like this:

2008

A 0

but I really want to get the second result, because if there is no 2008's records, the right answer of the query ought to be 0.

Please have a test based on the Adventrue Works., thanks!

|||

"because if there is no 2008's records, the right answer of the query ought to be 0" - well, the "right" answer depends on the scenario, but maybe applying CoalesceEmpty() will help you, like:

With

Member [Measures].[OrdersNoNull] as

CoalesceEmpty([Measures].[Order Count],0)

select

{[Date].[Calendar].[Month].&[2004]&[7],

[Date].[Calendar].[Month].&[2004]&Music} on 0,

{[Measures].[Order Count],

[Measures].[OrdersNoNull]} on 1

from [Adventure Works]

-

July 2004 August 2004
Order Count 976 (null)
OrdersNoNull 976 0

|||

Puri , you don't catch my mean. Use your example, you get the answer:

July 2004 August 2004
Order Count 976 (null)

And this is also what I want. But I got the answer:

July 2004

Order Count 976

The Agust 2004 column is missing. That's my problem. I run the MDX , and return a result without August 2004 column. If the result is (null), that's OK, that's what exactly I want. My problem is not to change (null) to 0. My problem is just the column is missing.

Thanks.

|||What tool are using to run your MDX query? My results came from Management Studio - so are you saying that you don't get the same results, when you run the above query in Management Studio?|||

Yes, me in Management Studio too. And I also tried the ADOMD.net, the same result.

You could try to only select one Measure like me have done.

Thanks.

|||To be clear, could you post an actual Adventure Works query, with the results you get in Management Studio, so that others can try to reproduce your problem?|||

eh,you could test it at a very simple way.

Just in the MDX you select a Time not existed. For example, if there is from 2000 to 2008's data in the cube, and no 2050 's data in the cube. Then you JUST select the 2050's in the MDX query. Then you will get the result I said. the 2050's column is missing, not the (NULL).

|||

I think it sounds very reasonable though? You dont have any record of the year you specified in your MDX query, then of course the result retured with nothing on that year?

With best regards,

Yours sincerely,

MDX-why the null result is missing?

Hi,friends, this is a newbie quetion about MDX.

I just write the MDX below:

select KPIValue("ADTD")on rows, {[Time].[TimeLevel].[Year].&[2007] } on columns from [TargetCube] where [Agent].[AgentMember].&[2]

And this return the result very well:

2007

ADTD 128

Then I change the MDX to this:

select KPIValue("ADTD")on rows, {[Time].[TimeLevel].[Year].&[2007],[Time].[TimeLevel].[Year].&[2008]} on columns from [TargetCube] where [Agent].[AgentMember].&[2]

And this return the same result:

2007

ADTD 128

It's very strange to me. Because there is no 2008's record in the Cube, I think the result ought to be :

2007 2008

ADTD 128 0

But why the result just makes the 2008's column Missing?

Thanks!

What is the MDX formula for KPIValue("ADTD"); and can you reproduce this problem with a KPI query in Adventure Works?|||

the MDX formula for KPIvalue("ADTD") is just refer to an Measure which Count the records of the facttable. I think this is not the answer. You could reproduce this problem with a KPI query in Adventrue Works.

And not only the KPI query, but every MDX query is like this. It looks like it's a common law of the MDX. You could have a simple test like this:

select ([Measures].Angel) on rows, {[Time].[TimeLevel].[Year].&[2008]} on columns from [Cube] where [Agent].[AgentLevel].&[2]

Because there is no 2008's records in the facttable, and you will get the result like this:

A

not like this:

2008

A 0

but I really want to get the second result, because if there is no 2008's records, the right answer of the query ought to be 0.

Please have a test based on the Adventrue Works., thanks!

|||

"because if there is no 2008's records, the right answer of the query ought to be 0" - well, the "right" answer depends on the scenario, but maybe applying CoalesceEmpty() will help you, like:

With

Member [Measures].[OrdersNoNull] as

CoalesceEmpty([Measures].[Order Count],0)

select

{[Date].[Calendar].[Month].&[2004]&[7],

[Date].[Calendar].[Month].&[2004]&Music} on 0,

{[Measures].[Order Count],

[Measures].[OrdersNoNull]} on 1

from [Adventure Works]

-

July 2004 August 2004
Order Count 976 (null)
OrdersNoNull 976 0

|||

Puri , you don't catch my mean. Use your example, you get the answer:

July 2004 August 2004
Order Count 976 (null)

And this is also what I want. But I got the answer:

July 2004

Order Count 976

The Agust 2004 column is missing. That's my problem. I run the MDX , and return a result without August 2004 column. If the result is (null), that's OK, that's what exactly I want. My problem is not to change (null) to 0. My problem is just the column is missing.

Thanks.

|||What tool are using to run your MDX query? My results came from Management Studio - so are you saying that you don't get the same results, when you run the above query in Management Studio?|||

Yes, me in Management Studio too. And I also tried the ADOMD.net, the same result.

You could try to only select one Measure like me have done.

Thanks.

|||To be clear, could you post an actual Adventure Works query, with the results you get in Management Studio, so that others can try to reproduce your problem?|||

eh,you could test it at a very simple way.

Just in the MDX you select a Time not existed. For example, if there is from 2000 to 2008's data in the cube, and no 2050 's data in the cube. Then you JUST select the 2050's in the MDX query. Then you will get the result I said. the 2050's column is missing, not the (NULL).

|||

I think it sounds very reasonable though? You dont have any record of the year you specified in your MDX query, then of course the result retured with nothing on that year?

With best regards,

Yours sincerely,

Friday, March 9, 2012

MDX question

i'm getting the following error on the code below.

TITLE: Microsoft Visual Studio

Query preparation failed.


ADDITIONAL INFORMATION:

Subselects only support the COLUMNS axis. (msmgdsrv)

I'm trying to replicate in MDX something I do in SQL code where I create two temp tables and then use a exists statement to get the rows from the first temp table that do not exist in the second temp table.

exists((select{ ([CUSTOMER JOB].[By Cust-Title-Job].[Title Name].ALLMEMBERS ) }on columns from ( SELECT ( filter([CUSTOMER JOB].[By Cust-Title-Job].[Title Name], [Measures].[Billed Sales Amount]>0)

) ON COLUMNS FROM ( SELECT ( [PREP CONTROL HDR].[Format Group].&[HP_Misc] ) ON COLUMNS FROM ( SELECT ( (lastperiods(12,tail(filter({[Job Complete Date].[Calendar Full].[Month].members* [Measures].[Billed Sales Amount]} as s, Not IsEmpty(s.current)),1).item(0).item(0))) ) ON COLUMNS FROM [DW PREP ARCHIVE]))) ),

(select{ ([CUSTOMER JOB].[By Cust-Title-Job].[Title Name].ALLMEMBERS ) } ON columns from ( SELECT ( filter([CUSTOMER JOB].[By Cust-Title-Job].[Title Name], [Measures].[Billed Sales Amount]>5000)

) ON COLUMNS FROM ( SELECT ( [PREP CONTROL HDR].[Format Group].&[HP_Misc] ) ON COLUMNS FROM ( SELECT ( (lastperiods(12,tail(filter({[Job Complete Date].[Calendar Full].[Month].members* [Measures].[Billed Sales Amount]} as s, Not IsEmpty(s.current)),1).item(0).item(0))) ) ON COLUMNS FROM [DW PREP ARCHIVE]))) ),

[Measures].[Billed Sales Amount] )

i was able to get the following to run however it seems to be ignoring the Except portion or the code. it only returns the first set not the difference between the sets.

trying to get the difference between two different sets of Customer/ title names

SELECT NON EMPTY { [Measures].[Billed Sales Amount] } ON COLUMNS,

NON EMPTY { ([CUSTOMER JOB].[By Cust-Title-Job].[Title Name].ALLMEMBERS ) } ON ROWS

FROM ( SELECT ( EXCEPT({filter({([CUSTOMER JOB].[By Cust-Title-Job].[Title Name]*[PREP CONTROL HDR].[Format Group].&[HP_Misc])}, [Measures].[Billed Sales Amount]>0)},

{filter({([CUSTOMER JOB].[By Cust-Title-Job].[Title Name]*[PREP CONTROL HDR].[Format Group].&[Prep])}, [Measures].[Billed Sales Amount]>5000)}) ) ON COLUMNS

FROM ( SELECT ( (lastperiods(12,tail(filter({[Job Complete Date].[Calendar Full].[Month].members* [Measures].[Billed Sales Amount]} as s, Not IsEmpty(s.current)),1).item(0).item(0))) ) ON COLUMNS FROM [DW PREP ARCHIVE]))

MDX Question

I have a cube that I have to calculate a 100 Weight for each Measure. Currently I have created Calculated Members to the tune of what you see below:

CREATEMEMBERCURRENTCUBE.[MEASURES].[AccrualCostCWT]

AS (IIF(([Measures].[Accrual Cost]/[Measures].[Lbs]) = 0, 0,([Measures].[Accrual Cost]/[Measures].[Lbs])*100)),

FORMAT_STRING = "#,#.00",

NON_EMPTY_BEHAVIOR = { [Lbs] },

VISIBLE = 1;

CREATEMEMBERCURRENTCUBE.[MEASURES].[BrokerCostCWT]

AS (IIF(([Measures].[Broker Cost]/[Measures].[Lbs]) = 0, 0, ([Measures].[Broker Cost]/[Measures].[Lbs])*100)),

FORMAT_STRING = "#,#.00",

NON_EMPTY_BEHAVIOR = { [Lbs] },

VISIBLE = 1;

What I would like to do is create an MDX Statement that will calculate the 100 Weight (CWT) for each measure and post it next to the measure. I am sure that there is a way to do this but I am not good enough at MDX to determine what I need to do.

This is running on SQL Server 2005 service pack 2 with the latest critical updates.

Sorry, but I don't understand the "post it next to the measure" part? You just want to cells next to each other in the cell set returned by a query?

Thanks,
Bryan

|||

Thanks for wanting clarification. Here is what I am looking for.

I have a measure with a dollar amount such as accrualCost, brokerCost, etc. (20 Columns like this)

I also have a measure called LBS, I need a way to do the CWT without creating a number of Members. If I could just have one member to work this it would be great.

I would like to see it like either of the following ways.

Amount CWT accrualCost 48,247 3.7 brokerCost 29,297 4.2 accrualCost brokerCost Amount 48,247 29,297 CWT 3.7 4.2

Let me know if you need further details.

Thanks,

Scott

|||

I think I'm starting to see where you're going with this. Let me ask, where is the Amount measure coming from? When you say "Amount" are you actually referring the value of whatever measure you are referencing?

B.

MDX Question

I have a cube that I have to calculate a 100 Weight for each Measure. Currently I have created Calculated Members to the tune of what you see below:

CREATE MEMBER CURRENTCUBE.[MEASURES].[AccrualCostCWT]

AS (IIF(([Measures].[Accrual Cost]/[Measures].[Lbs]) = 0, 0,([Measures].[Accrual Cost]/[Measures].[Lbs])*100)),

FORMAT_STRING = "#,#.00",

NON_EMPTY_BEHAVIOR = { [Lbs] },

VISIBLE = 1;

CREATE MEMBER CURRENTCUBE.[MEASURES].[BrokerCostCWT]

AS (IIF(([Measures].[Broker Cost]/[Measures].[Lbs]) = 0, 0, ([Measures].[Broker Cost]/[Measures].[Lbs])*100)),

FORMAT_STRING = "#,#.00",

NON_EMPTY_BEHAVIOR = { [Lbs] },

VISIBLE = 1;

What I would like to do is create an MDX Statement that will calculate the 100 Weight (CWT) for each measure and post it next to the measure. I am sure that there is a way to do this but I am not good enough at MDX to determine what I need to do.

This is running on SQL Server 2005 service pack 2 with the latest critical updates.

Sorry, but I don't understand the "post it next to the measure" part? You just want to cells next to each other in the cell set returned by a query?

Thanks,
Bryan

|||

Thanks for wanting clarification. Here is what I am looking for.

I have a measure with a dollar amount such as accrualCost, brokerCost, etc. (20 Columns like this)

I also have a measure called LBS, I need a way to do the CWT without creating a number of Members. If I could just have one member to work this it would be great.

I would like to see it like either of the following ways.

Amount CWT accrualCost 48,247 3.7 brokerCost 29,297 4.2 accrualCost brokerCost Amount 48,247 29,297 CWT 3.7 4.2

Let me know if you need further details.

Thanks,

Scott

|||

I think I'm starting to see where you're going with this. Let me ask, where is the Amount measure coming from? When you say "Amount" are you actually referring the value of whatever measure you are referencing?

B.

Saturday, February 25, 2012

Mdx Query doubt about years?

Hi,
The below query which has hardcoded year ending values works fine.

What i want to do is if I pass on last 3 years or last 4 years etc as parameter along with current year it should bring back the results accordingly for the required years.

with
member [YearEnding].[CurrYear] as '[YearEnding].[All YearEnding].[2005]'
select
non empty {[Product].Children, Product.[All Product]} on columns,
non empty Filter({ {[Measures].[stock Quantity Ola] } * { [YearEnding].Children} }, (([YearEnding] = [YearEnding].[2005]) or ([YearEnding] = [YearEnding].[2004]) or ([YearEnding] = [YearEnding].[2003])) ) on rows
from Stock
Help much appreciated
Many Thanks

VeeraFirstly, you could run into problems using '=' operator to test for dimension members - this blog entry by Mosha Pasumanskyexplains why:

http://sqljunkies.com/WebLog/mosha/archive/2004/11/4.aspx
>>
Comparing members in MDX
...
>>

Since measures are not on columns, this looks like OLE DB Provider for OLAP, for which the MDX query has to be converted to an expression, to add parameters. Assuming a multi-select parameter like "SelectedYears", with selected string values like "[YearEnding].[2003]", etc, then the filter condition can be built using Join():

+ "Count(Intersect({[YearEnding].CurrentMember}, {"
+ Join(Parameters!SelectedYears.Value, ",")
+ "})) = 1) on rows from Stock"

Monday, February 20, 2012

MDX Parameter Query

I am attempting to add a date parameter to a RS MDX query. Below I have included my query. I have been following a olapasandrs.asp white paper on microsoft.com, but I keep receiving an error message - "The expression for the query 'query name' contains an error: [BC30648] String constants must end with a doube quote"
If someone would please be kind enough to take a look at my query and point out any problems I would appreciate it!!
="SELECT{[Measures].[Gm] ,[Measures].[Sales],[Measures].[COS],[Measures].[Rebate],[Measures].[Adjustment]} ON AXIS(0) , {nonemptycrossJoin([products].[Glcls].Members,[segdiv].[divname].Members)} ON AXIS(1) ,{[Time].Members} ON AXIS(2) FROM vc_rebates Where (" & Parameters!pTime.Value & ")"
--
Message posted via http://www.sqlmonster.comI have an update:
I have changed my query to read-
="SELECT{[Measures].[Gm] ,[Measures].[Sales],[Measures].[COS],[Measures].[Rebate],[Measures].[Adjustment]} ON AXIS(0),
{nonemptycrossJoin([products].[Glcls].Members,[segdiv].[divname].Members)} ON AXIS(1),
{Descendants([Time].[All Time],[Time].[Month])} ON AXIS(2)
FROM vc_rebates Where(" & Parameters!pTime.Value & ")"
I still receive the error: "[BC30648] String constants must end with a doube quote" though...
Any help would be appreciated!!!!
--
Message posted via http://www.sqlmonster.com|||Jason via SQLMonster.com wrote:
> I still receive the error: "[BC30648] String constants must end with
> a doube quote" though...
you have to write a double quote at the beginning and end of each line.
="SELECT{[Measures].[Gm]
,[Measures].[Sales],[Measures].[COS],[Measures].[Rebate],[Measures].[Adjustm
ent]} ON AXIS(0), " +
"{nonemptycrossJoin([products].[Glcls].Members,[segdiv].[divname].Members)}
ON AXIS(1), " +
"{Descendants([Time].[All Time],[Time].[Month])} ON AXIS(2) " +
"FROM vc_rebates Where(" & Parameters!pTime.Value & ")"
regards
Frank
www.xax.de|||Thank you Frank!
I have changed the query statement to read:
="SELECT{[Measures].[Gm] ,[Measures].[Sales],[Measures].[COS],[Measures].[Rebate],[Measures].[Adjustment]} ON Columns, " +
"Non Empty { [products].[Glcls].Members } ON Rows, " +
"Non Empty { Descendants([segdiv].[All segDiv],[segDiv].[Divname],LEAVES) } ON Pages, " +
"Non Empty { Descendants([Time].[All Time],[Time].[Month],LEAVES) } ON Sections " +
"FROM vc_rebates " +
"Where (" & Parameters!pDate.Value & ")"
Now I am receving a new error message, "The expression for the query 'Query Name' contains an error: [BC30451] Name 'Non' is not declared".
Do you have any additional suggestions?
Thanks
--
Message posted via http://www.sqlmonster.com|||Jason via SQLMonster.com wrote:
> I have changed the query statement to read:
> Now I am receving a new error message, "The expression for the query
> 'Query Name' contains an error: [BC30451] Name 'Non' is not
> declared".
> Do you have any additional suggestions?
OK...now your MDX-Statement seems to be wrong.
The "Name 'Non' is not declared seems to result of the "Non Empty"
Did you test your MDX-Query in mdx-query-application
(Start-Progs-SQLServer-Analysis Services -MDX-Application)? Usually without
the "-Quotes!! and filled up with the parameter-value.
For Test:
Erase the Non Empty-Clause
regards
Frank
www.xax.de|||Thank you for your response Frank,
I have one last post for you...
I have been able to deploy the report and have not encoutnered any errors. Upon selecting the parameter though I am reeiving an error message from reporting services:
Exception of type Microsoft.ReportingServices.ReportRendering.ReportRenderingException was thrown. (rrRenderingError) Get Online Help
Exception of type Microsoft.ReportingServices.ReportRendering.ReportRenderingException was thrown.
Operation is not valid due to the current state of the object.
If I remove the parameter the report runs fine. Do you have any suggestions? I have posted the parameter query statement below.
with Member [Measures].[TimeMemberUniqueName] as '[Time].currentmember.UniqueName' member [Measures].[TimeDisplayName] as 'space([Time].Currentmember.Level.Ordinal *4) + Time.Currentmember.Name'
Select {[Measures].[TimeMemberUniqueName],[Measures].[TimeDisplayName]} on Columns,
{[Time].members} on rows
from vc_rebates
Thank you in advance!!
--
Message posted via http://www.sqlmonster.com|||Frank,
Problem solved!!
There were some simple formatting issues that I fixed.
Your help is greatly appreciated!!
--
Message posted via http://www.sqlmonster.com

MDX issue with SUM function and + operator


Hi,

Facing a problem with the sum and aggregate functions when using the + operator
The simplified representation of the problem is as below

The following query returns null.

[Measures].[xyz] is a base measure, no mdx calculation

with member TestValue as
'[Measures].[xyz] + [Measures].[xyz]'

member SummedValue as
'sum (
{
DimensionA.Level2.Member1,
DimensionA.Level2.Member2,
DimensionA.Level2.Member3,
DimensionA.Level2.Member4
}
,TestValue
)

select
SummedValue on columns
from <cube>

The above query returns a valid integer value

when TestValue is just '[Measures].[xyz]' and not the sum(+) or subtraction(-),
though it works when it is multiplication or division (* or /).

Is there anything wrong in the usage or is there a workaround.

Regards

I ran the following query against the AdventureWorks cube, and it delivered the desired results.

Code Snippet

with member TestValue as

'[Measures].[Internet Order Count]+[Measures].[Internet Order Count]'

member SummedValue as

'sum (

{

[Customer].[Customer Geography].[State-Province].&[FL]&[US],

[Customer].[Customer Geography].[State-Province].&[AL]&[US],

[Customer].[Customer Geography].[State-Province].&[GA]&[US],

[Customer].[Customer Geography].[State-Province].&[MI]&[US]

}

,TestValue

)'

select

SummedValue on columns

from [Adventure Works]

Can you give some details on how your cube differs from this?

|||

we have this problem only in a particular environment.

Is this dependent on Service packs of SQL Server or 32/64 bit versions of SQL Server.

Regards

|||I tested in an XP SP2 32-bit / SQL Server 2005 SP2 environment. I can try a few others tomorrow. It would be helpful if you let the forum know what type of environment you are running in.|||

This might be a bit of a long shot, but try changing your expression to make it a bit more explicit. The '+' operator is overloaded to also act as a union operator, because you are passing in two members, maybe SSAS is choosing to make a set of two members rather than doing a numeric addition.

Try changing your calc expression from

with member TestValue as
'[Measures].[xyz] + [Measures].[xyz]'

To:

with member TestValue as ([Measures].[xyz]) + ([Measures].[xyz])

Note that the single quotes around inline calculated members are no longer required in SSAS 2005 and in fact it is better not to include them as SSAS can then report the location of any errors with more accuracy. (plus you get better syntax coloring support in SSMS)

|||

thanks for the quick replies...

this does not work in a 64-bit SQL Server SP1 ......SSAS version 9.00.2176.00 environment

but works in 32-bit SQL Server SP2......SSAS version 9.00.3042.00

this lists the fixes in SQL Server 2005 SP2

http://support.microsoft.com/default.aspx/kb/921896

is it linked to this fix

919957 (http://support.microsoft.com/kb/919957/) FIX: Some cells return the NULL value instead of returning the actual value when you query a dimension that contains a parent/child hierarchy in a SQL Server 2005 Analysis Services cube

Regards