Showing posts with label member. Show all posts
Showing posts with label member. Show all posts

Friday, February 24, 2012

Calculations Script Order and Formatting

I have a parent-child dimension for Accounts with a calculated member drapped off of the top level that figures Net Earnings % using a measure called Amount. As described by the name of the member, I need this expressed as a percentage. I am using this calc in the same view as a (Shell/Utility) Time Calculations dim that figures Year-to-date, Prior Year-to-date, YTD % Change, etc.... Depending on the order of the calculations in the calculations script I get different results. If I put the formula for the Net Earnings % before the MDX for the Time Calculations the results comes out correct but the formating gets overidden by the formating applied when the Time Calulations are applied. So the Net Earnings % for [YTD] and [YTD PY] are expressed as decimals and [YTD % Change] is expressed as a percentage. If I flip the order in the calculations script the formating gets corrected because the formatting of the Net Earnings % get applied last but my results for Net Earnings % are incorrect for [YTD % Change] because they were applied after the Time Calculations and end up applying the formula using the reults (the percentages) of the [YTD % Change] calc instead of the numbers used to make up that percentage.

Is there a way to put the Net Earnings % MDX before the Time Calculations MDX so that the results are correct for [YTD % Change] and reapply the formating of percent to [YTD] and [YTD PY] after the formatting of the Time Calculations get applied?

Nevermind, I figured it out. I placed the Net Earnings % MDX before the Time Calculations MDX and placed the following MDX after the Time Calculations MDX:

Code Snippet

Scope({[Account].[Account Hierarchy].[Net Earnings%]});

FORMAT_STRING(THIS) = "Percent";

End Scope;

|||

Nevermind, I figured it out. I placed the Net Earnings % MDX before the Time Calculations MDX and placed the following MDX after the Time Calculations MDX:

Code Snippet

Scope({[Account].[Account Hierarchy].[Net Earnings%]});

FORMAT_STRING(THIS) = "Percent";

End Scope;

Calculations Question

Hello,

Is there a way to make a Calculated Member aggregatable? I want to create a Calculated Member that performs a certain formula at the leaf level only. On the upper levels of the hierarchy I want the value aggregated, not the formula re-applied. Is there a way to achieve this?

Another question, is there a way to apply a special formula for a measure? and what is the "MeasureExpression" Property of a measure to be used for?

Thanks

For the first part:

You could create real measure that has all values as NULL. This will not take any space in database. Then you assign calculations in your calculated area and this measure will behave like real measure. This is based on Mosha Pasumansky suggestion here:

http://sqljunkies.com/WebLog/mosha/archive/2006/11/16/sqlpass_udm_presentation.aspx

Quote:

6. It isn't a problem that calculated measures don't aggregate up. If the designer need to add calculated measure which has aggregation semantics of a real measure, than there is very simple way to do it. Add a real measure to the measure group, and specify NULL as its column binding. It will cost nothing during processing, the partition size is going to be exactly the same, because AS will easily detect that measure value is constant and will compress it to 0 bits. But then in MDX Script, when expressions are assigned to that measure - they will aggregate up using measure's aggregation function - and it should work very efficiently too.

Some info about "MeasureExpression" property can be found in this thread: http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=768757&SiteID=17

Vidas Matelis

Calculations involving NULLs

I have a Calulated Member that is calculating an average.
[Measures].[Overall Satisfaction]/[Measures].[Count Of Survey]
The problem is that for some of the items there are no surveys, so there are
NULL values in the database for these.
When I view the cube as a pivot table in Excel I am getting #NUM! for any
dimentions that do not have actual numbers.
How can I change my calculation so it will just return NULL instead of the
dreaded #NUM! value that drives managers so crazy?
Thank you!
:-J
Jeremy
Use COALESCE or ISNULL function to change a NULL to a valid value or a
space.
Anith
|||REGARDS MY EXAMPLE
[Measures].[Average] AS ' IIF(ISNULL([Measures].[Count Of Survey]), NULL, [Measures].[Overall Satisfaction]/[Measures].[Count Of Survey]) '
You colud use ISNULL() with a tuple, for example ISNULL(([Time].[2004].CURRENTMEMBER, [Measures].[Overall Sastisfaction))
I hope it would help you
Agustin
|||Thank you for the help it got me going on the right track.
What I ended up with was:
IIF([Measures].[Count Of Survey]=0, NULL, [Measures].[Overall
Satisfaction]/[Measures].[Count Of Survey])
This seems to work perfectly!
Thanks agian!
-Jeremy
"Agustin Brau" <anonymous@.discussions.microsoft.com> wrote in message
news:759562E4-29AE-4697-AEE4-4290AF5A524D@.microsoft.com...
> REGARDS MY EXAMPLE
> --
> [Measures].[Average] AS ' IIF(ISNULL([Measures].[Count Of Survey]), NULL,
[Measures].[Overall Satisfaction]/[Measures].[Count Of Survey]) '
> --
> You colud use ISNULL() with a tuple, for example
ISNULL(([Time].[2004].CURRENTMEMBER, [Measures].[Overall Sastisfaction))
> I hope it would help you
> Agustin

Calculations involving NULLs

I have a Calulated Member that is calculating an average.
[Measures].[Overall Satisfaction]/[Measures].[Count Of Surve
y]
The problem is that for some of the items there are no surveys, so there are
NULL values in the database for these.
When I view the cube as a pivot table in Excel I am getting #NUM! for any
dimentions that do not have actual numbers.
How can I change my calculation so it will just return NULL instead of the
dreaded #NUM! value that drives managers so crazy?
Thank you!
:-J
JeremyUse COALESCE or ISNULL function to change a NULL to a valid value or a
space.
Anith|||REGARDS MY EXAMPLE
--
[Measures].[Average] AS ' IIF(ISNULL([Measures].[Count Of Su
rvey]), NULL, [Measures].[Overall Satisfaction]/[Measures].[
Count Of Survey]) '
--
You colud use ISNULL() with a tuple, for example ISNULL(([Time].[200
4].CURRENTMEMBER, [Measures].[Overall Sastisfaction))
I hope it would help you
Agustin|||Thank you for the help it got me going on the right track.
What I ended up with was:
IIF([Measures].[Count Of Survey]=0, NULL, [Measures].[Overal
l
Satisfaction]/[Measures].[Count Of Survey])
This seems to work perfectly!
Thanks agian!
-Jeremy
"Agustin Brau" <anonymous@.discussions.microsoft.com> wrote in message
news:759562E4-29AE-4697-AEE4-4290AF5A524D@.microsoft.com...
> REGARDS MY EXAMPLE
> --
> [Measures].[Average] AS ' IIF(ISNULL([Measures].[Count Of Survey])
, NULL,
[Measures].[Overall Satisfaction]/[Measures].[Count Of Survey]) 'reen">
> --
> You colud use ISNULL() with a tuple, for example
ISNULL(([Time].[2004].CURRENTMEMBER, [Measures].[Overall Sastisfaction))[vbc
ol=seagreen]
> I hope it would help you
> Agustin[/vbcol]

Sunday, February 19, 2012

calculation problem

Hello,

We have time dimension (month, week)

and fact table, total_revenue, no_of_work_day, order, order type....

We added a calculated member : Ave revenue/work_day
Expression: "[Measures].[Tot Revenue]/[Measures].[No Of Work Day]"
in BI studio, but result is wrong.

Something wrong with 'no_of_work_day' , but how to correct it?

Thank you very much for any help.

In spite of using calculated member inside cube, try to create a named calculation inside datasourceview!?

In the table of datasourceview, right-click and add a named calculation a insert your formula TotRevenue/NoOfWorkDay...

Regards!

|||

Can you show us your mdx query?

You try using the SUM(...) function on the measures members and dividing with it...

I would also like to say that you can create your calculated member in the cube...


Regards,

|||Thank you very much PedroCGD and Luis for the advice,

I tried using named calculation, it works. Great!

What is different between named calculation and calculate command inside cube?

I really appreciated your help.
|||

Dear Olap_user,

Always try to use named calculations... only when you need to calculate inside aggregations you use calculated member. The big advantage of using named calculation is that the system spend time to do calculates only once, and with calculated member each time you query the cube. So:

Named Calculation > each time your process cube

Calculated member > each time you query the cube!

Helped you?

Regards!!!

|||Thank you very much for the detail explanation, using Named Calculation is better for the performance.

Your explanation is very helpful.

Thanks a lot.

Tuesday, February 14, 2012

Calculating Length of a Member in MDX

hi,

can we calculate the length of any member in mdx query?i have a dimension having searched keywords like a,aa,abc,abcd... and so on.i want to filter the data based on length of these characters .Is it possible in mdx query?i am using MS sql server analysis services 2005.

Thanks

This is not too hard.

You would use something like Filter([Product].[ProductCode].members, vba!len([Product].[ProductCode].Currentmember.Name) = 3)

Another alternative that might give you better performance if you are going to do a lot of filtering on the length would be to calculate the length in a calculated column in the DSV and add it as an attribute to the dimension, in this way it can be indexed by SSAS rather than being calculated on the fly.

|||

Thanks for the Quick Reply Darren.

But in mdx i didnt find any function as you mentioned "vballen".i suppose this means variable length.can u suggest me how do i create such function in mdx?

Thanks

Sunday, February 12, 2012

Calculating AVG Values

Hi mates,


Code Snippet

WITH
MEMBER [MEASURES].X AS AVG([MEASURES].[ITEM VALUE])
MEMBER MEASURES.PARENTID

AS [DEPARTMENT].DEPARTMENTS].CURRENTMEMBER.PARENT.NAME

MEMBER MEASURES.CHILDRENID AS
GENERATE(DESCENDANTS([DEPARTMENT].[DEPARTMENTS].CURRENTMEMBER),
[DEPARTMENT].[DEPARTMENTS].CURRENTMEMBER.NAME, " - ")
MEMBER MEASURES.CHILDRENNAME AS
GENERATE(DESCENDANTS([DEPARTMENT].[DEPARTMENT].CURRENTMEMBER),
[DEPARTMENT].[DEPARTMENT].CURRENTMEMBER.NAME, " - ")
SELECT
CROSSJOIN([TIME].YEAR.&[2006], [TIME].[DATEHIER].[MONTH].MEMBERS,
DESCENDANTS([DEPARTMENT].[2],
[DEPARTMENT].[DEPARTMENTS].CURRENTMEMBER, SELF_AND_BEFORE)) ON ROWS ,

{(MEASURES.PARENTID), (MEASURES.CHILDRENID), (MEASURES.CHILDRENNAME),

[MEASURES].X} ON COLUMNS

FROM OLAPDEV
WHERE ([ITEM].[78])

this MDX Query returns the following result


Year
Month
Department
Department ParentId
Department ChildrenIds
Department ChildrenNames
ItemValue (Measure Value)

This returns sum of Item value for each month,year and deparmemnt.

But I need Avg of Item Values for each month, year and department

please help me


thanks

anand

You have an "Item Value" measure defined. Add another measure which is the Count aggregate function instead of the Sum aggregate function. Now that you have the Sum and the Count, you can simply do Sum/Count and calculate the average. So your MDX would start like the following:

WITH
MEMBER [MEASURES].X AS IIf(IsEmpty([MEASURES].[ITEM VALUE COUNT]),null,[MEASURES].[ITEM VALUE]/[MEASURES].[ITEM VALUE COUNT])

|||

It is not returning the correct value,

could not get count for each year, month and by department.

count to be calculated , using group of year, month and department,

but by above solution i couldn't get that

|||You're going to need to give us more info if you want our help. We can't read your mind. What precisely is wrong? What is the correct value? What is currently being returned?|||

Code Snippet

WITH

MEMBER [MEASURES].X AS [MEASURES].[ITEM VALUE]

MEMBER MEASURES.PARENTID AS

[DEPARTMENT].[DEPARTMENTS].CURRENTMEMBER.PARENT.NAME MEMBER

MEASURES.CHILDRENID AS

GENERATE(DESCENDANTS([DEPARTMENT].[DEPARTMENTS].CURRENTMEMBER),

[DEPARTMENT].[DEPARTMENTS].CURRENTMEMBER.NAME, " - ")

MEMBER MEASURES.CHILDRENNAME AS

GENERATE(DESCENDANTS([DEPARTMENT].[DEPARTMENT].CURRENTMEMBER),

[DEPARTMENT].[DEPARTMENT].CURRENTMEMBER.NAME, " - ")

SELECT

CROSSJOIN([TIME].YEAR.&[2006],

[TIME].[DATEHIER].[MONTH].MEMBERS,

DESCENDANTS([DEPARTMENT].[2],

[DEPARTMENT].[DEPARTMENTS].CURRENTMEMBER, SELF_AND_BEFORE)) ON ROWS ,

{(MEASURES.PARENTID), (MEASURES.CHILDRENID),

(MEASURES.CHILDRENNAME), [MEASURES].X} ON COLUMNS

FROM IBMTEST

WHERE ([ITEM].[78])

above query returns following results, which returns sum of itemvalue group by year, month, department.

Year #Month #Department #Parent.Dept #Child.deptIDs #Child.DeptNames #Value

2006 1 2 2 2 All - Corporate 337710

2006 2 2 2 2 All - Corporate 328059

2006 3 2 2 2 All - Corporate 432346

2006 4 2 2 2 All - Corporate 342362

2006 5 2 2 2 All - Corporate (null)


my requirement is avg(itemvalue) group by year, month and department.

WITH
MEMBER [MEASURES].X AS IIf(IsEmpty([MEASURES].[ITEM VALUE COUNT]),null,[MEASURES].[ITEM VALUE]/[MEASURES].[ITEM VALUE COUNT])

if i use your above calculated member it gives error for using item [MEASURES].[ITEM VALUE COUNT],

WITH
MEMBER [MEASURES].X AS IIf(IsEmpty( COUNT([MEASURES].[ITEM VALUE])),null,[MEASURES].[ITEM VALUE]/ COUNT([MEASURES].[ITEM VALUE]))

i removed count and used count(measures.itemvalue), this is also returing the same value as sum. even using AVG(MEASURES.ITEMVLAUE) also not

working.

i think this is not working out since crossjoin is used. i hope this is more clear to u.

Friday, February 10, 2012

calculated members WHERE statement?

i am trying to figure out how to use MDX and a WHERE statement in the calculated member expression textbox. Every time i try i get a syntax error, and can't seem to find an example anywhere. Is it even possible?

I am trying to make a calculated member (measure) but I need to filter on only a few values of a DIM. I have seen how to write an MDX query and do this, but I need a permenant calculated measure.

Any insights? Thanks

Please keep in mind the difference between an MDX expression (used in defining a calculated member) and an MDX query (which can include a WHERE clause). You can try using Filter() in your MDX expression instead.|||i could never get that to work, i went down the road of making a named calculation and using that in my calculated measure

Calculated Members when generating a report model

I created and deployed calculated member as measures in my cube but when I generate a model in Reporting services the calculated members do not appear? Should they? or did I miss something? Anyone else experience this?

Thank you!

In get calculated members (calculated meaures) to surface in a report model, they have to be associated with a measure group. On the calculations tab in BIDS, click on the Calculation Properties button on the menu bar and then associate each calculated measure with a measure group. Recreate your report model and they should appear along with the measures that belong to that measure group.

HTH,

Dave Fackler

|||

Thank you, that was it! They are there now when I re-generate the model.

Janet

Calculated Members Problem

1. I got the price and the qty in the data source. when I create the
calculated member Amount = Qty * price, I found out the total is equal to the
total qty * total price.
How can I define the calculated member Amount = summation of (qty *
price).
2. secondly, I would like to count how many order line. How can I do it in
the calculated members?
"Kam" <Kam@.discussions.microsoft.com> wrote in message
news:55973F33-03AE-481D-91BF-18C5C3FEB85F@.microsoft.com...
> 1. I got the price and the qty in the data source. when I create the
> calculated member Amount = Qty * price, I found out the total is equal to
the
> total qty * total price.
> How can I define the calculated member Amount = summation of (qty *
> price).
>
Define a measure with source column = Qty * price

> 2. secondly, I would like to count how many order line. How can I do it in
> the calculated members?
>
Try defining a mesaure on OrderID_OrderLineID with aggregate function
"Count". But it depends on the structure of the fact table
Francesco Anti
|||I defined Qty * price.
but my problem is the total sales = total qty * total price. It is wrong.
How can I define the total sales = total (qty * price)?
"Francesco Anti" wrote:

> "Kam" <Kam@.discussions.microsoft.com> wrote in message
> news:55973F33-03AE-481D-91BF-18C5C3FEB85F@.microsoft.com...
> the
> Define a measure with source column = Qty * price
> Try defining a mesaure on OrderID_OrderLineID with aggregate function
> "Count". But it depends on the structure of the fact table
> Francesco Anti
>
>

Calculated Members Problem

1. I got the price and the qty in the data source. when I create the
calculated member Amount = Qty * price, I found out the total is equal to th
e
total qty * total price.
How can I define the calculated member Amount = summation of (qty *
price).
2. secondly, I would like to count how many order line. How can I do it in
the calculated members?"Kam" <Kam@.discussions.microsoft.com> wrote in message
news:55973F33-03AE-481D-91BF-18C5C3FEB85F@.microsoft.com...
> 1. I got the price and the qty in the data source. when I create the
> calculated member Amount = Qty * price, I found out the total is equal to
the
> total qty * total price.
> How can I define the calculated member Amount = summation of (qty *
> price).
>
Define a measure with source column = Qty * price

> 2. secondly, I would like to count how many order line. How can I do it in
> the calculated members?
>
Try defining a mesaure on OrderID_OrderLineID with aggregate function
"Count". But it depends on the structure of the fact table
Francesco Anti|||I defined Qty * price.
but my problem is the total sales = total qty * total price. It is wrong.
How can I define the total sales = total (qty * price)?
"Francesco Anti" wrote:

> "Kam" <Kam@.discussions.microsoft.com> wrote in message
> news:55973F33-03AE-481D-91BF-18C5C3FEB85F@.microsoft.com...
> the
> Define a measure with source column = Qty * price
>
> Try defining a mesaure on OrderID_OrderLineID with aggregate function
> "Count". But it depends on the structure of the fact table
> Francesco Anti
>
>

Calculated members are unbelievably slow

In general. Need help what are the top items I must check? My client is Excel Pivot table

I have one cal. member [NAV] from one fact table I am getting POSN TOTL CURR NAV BAL PTFC and OWNSHP PRCNTG

cal. mem [NAV] formula is below

Iif(([Investment].CurrentMember.Level.Name = "Investment Cd" or

[Investment].CurrentMember.Level.Name="Investment Type Cd") and

([Investor].CurrentMember.Level.Name="Investor Type Cd" or

[Investor].CurrentMember.Level.Name="Investor Cd" or

[Investor].CurrentMember.Level.Name="Investor Desc") ,

[Measures].[POSN TOTL CURR NAV BAL PTFC] * [Measures].[OWNSHP PRCNTG] ,

Iif([Investment].CurrentMember.Level.Name="Investment Cd" or

[Investment].CurrentMember.Level.Name="Investment Type Cd" ,

[Measures].[POSN TOTL CURR NAV BAL PTFC] ,

Iif(([Investor].CurrentMember.Level.Name="Investor Type Cd" or

[Investor].CurrentMember.Level.Name="Investor Cd" or

[Investor].CurrentMember.Level.Name="Investor Desc") ,

[Measures].[POSN TOTL CURR NAV BAL FUND] ,

Sum({[Investor].AllMembers}, [Measures].[POSN TOTL CURR NAV BAL FUND]))))

and hand full of simple calculations like this from different fact table

[Measures].[EQ UP 5P]/[Measures].[NAV]

Thank you - Ashok

Couple of suggestions:

1. Get rid of all IIF's and replace them with SCOPE as explained here: http://www.sqljunkies.com/WebLog/mosha/archive/2007/01/28/iif_performance.aspx

2. Revisit whether Sum({[Investor].AllMembers}, [Measures].[POSN TOTL CURR NAV BAL FUND])) is even correct. I think it isn't. It tries to sum up members from all levels of Investor dimension. This cannot be right. Also, it is going to be constant regardless of the current coordinate in Investor dimension, even though the rest of your expression carefully looks at the current coordinate in Investor.

|||

Thanks Mosha,

Because I have more then one IIF and I am new to MDX can I replace my NAV MDX with this ?

SCOPE (([Investment].CurrentMember.Level.Name = "Investment Cd" or [Investment].CurrentMember.Level.Name="Investment Type Cd")
and ([Investor].CurrentMember.Level.Name="Investor Type Cd" or [Investor].CurrentMember.Level.Name="Investor Cd"
or [Investor].CurrentMember.Level.Name="Investor Desc"));
This = [Measures].[POSN TOTL CURR NAV BAL PTFC] * [Measures].[OWNSHP PRCNTG];
SCOPE ([Investment].CurrentMember.Level.Name="Investment Cd" or [Investment].CurrentMember.Level.Name="Investment Type Cd");
This = [Measures].[POSN TOTL CURR NAV BAL PTFC];
SCOPE ([Investor].CurrentMember.Level.Name="Investor Type Cd" or [Investor].CurrentMember.Level.Name="Investor Cd" or
[Investor].CurrentMember.Level.Name="Investor Desc"));
This = [Measures].[POSN TOTL CURR NAV BAL FUND];
SCOPE ([Investor].AllMembers)
This = [Measures].[POSN TOTL CURR NAV BAL FUND];
END SCOPE;

Thank you - Ashok

I just tried this and I am getting syntax error

CREATE MEMBER CURRENTCUBE.[MEASURES].[NAV]

AS SCOPE ([Investor].AllMembers);

This = [Measures].[POSN TOTL CURR NAV BAL PTFC] * [Measures].[OWNSHP PRCNTG];

END SCOPE;,

VISIBLE = 1 ;

|||

Looks like you are still learning the syntax of MDX scripts. Here are two resources which have examples of how to convert IIF to SCOPE:

1. AS2005 Performance Guide http://download.microsoft.com/download/8/5/e/85eea4fa-b3bb-4426-97d0-7f7151b2011c/SSAS2005PerfGuide.doc. (look for the MDX optimization section)

2. This blog also has an example: http://www.sqljunkies.com/WebLog/mosha/archive/2006/11/05/non_empty_behavior.aspx

Calculated Member? (Beginner)

I have a measure named "Person Count". I am trying to make a calculated measure that gives me the same result if i made a dataset and had "Person Count" filtered by [Crash][Is injury]&[yes] (which is under the Crash dimension. How would i write the query in mdx for the calculated measure. This is what i thought it should be:

[Measures].[Person Count] * [Crash].[Is Fatal Injury].&[Yes]

Where did i go wrong? I get nulls in the field. I did this before for another calculated member with a colegue, but i cant seem to remember exactly how it was written. And i cant get into his computer. Please help, i know its something little.

Figure out it needed a comma! which i tried before, but didnt use parenthesis!

here's the answer for future references!

( [Measures].[Person Count] , [Crash].[Is Fatal Injury].&[Yes] )

Calculated member?

I'm doing some reports and i need to create individual results as attributes
or Calculated members. I have a Hierachy called Injury with five options,
A-jury, B-injury, C-injury, and O-injury. The Query builder only lets me put
in the hierachy. So I need to get the "person count" (measure) for each
individual one, instead of all together. And i dont want to filter in
different datasets. I want them all in the same dataset as the total. How can
this be done? I've been scratching my head for a couple days now.Correction, i want them each seperate in the dataset with their values, as
well as the total.
"Tenchy" wrote:
> I'm doing some reports and i need to create individual results as attributes
> or Calculated members. I have a Hierachy called Injury with five options,
> A-jury, B-injury, C-injury, and O-injury. The Query builder only lets me put
> in the hierachy. So I need to get the "person count" (measure) for each
> individual one, instead of all together. And i dont want to filter in
> different datasets. I want them all in the same dataset as the total. How can
> this be done? I've been scratching my head for a couple days now.|||Have you tried working with MDX statements in the Anaysis Services managment
studio?
You could write it out how it's supposed to in the AS studio, then use it as
a classic mdx query in your report. You need to use a OLE DB connection for
your data source, though.
1) Instead of using the Analysis Services data source, create your data
source as OLE DB, and connect to your AS 2005 server through that.
2) Now you have the old school query interface. No help, but also no mess.
3) Create your non dynamic query in the SQL Server Management studio, by
connecting to your AS and work out the MDX
4) Copy paste your non dynamic query to create all your fields etc.
5) Make it dynamic by adding the =" and " and all the parameter names
Kaisa M. Lindahl Lervik
"Tenchy" <Tenchy@.discussions.microsoft.com> wrote in message
news:ACAFDA00-56BE-4B67-A028-73F852F67E34@.microsoft.com...
> Correction, i want them each seperate in the dataset with their values, as
> well as the total.
> "Tenchy" wrote:
>> I'm doing some reports and i need to create individual results as
>> attributes
>> or Calculated members. I have a Hierachy called Injury with five
>> options,
>> A-jury, B-injury, C-injury, and O-injury. The Query builder only lets me
>> put
>> in the hierachy. So I need to get the "person count" (measure) for each
>> individual one, instead of all together. And i dont want to filter in
>> different datasets. I want them all in the same dataset as the total. How
>> can
>> this be done? I've been scratching my head for a couple days now.|||Thats my problem, i dont know what the mdx code would be to do that. Because
i can do mdx in reporting services in the dataset as a calculated member. But
the code i put in there gives me all kinds of syntax errors. This is the code
i have right now.
SELECT { [Measures].[Vehicle Count], [Measures].[Injury Crashes],
[Measures].[Non-Fatal Injuries], [Measures].[Fatal Injuries],
[Measures].[CrashCount], [Measures].[Fatal Crashes] } ON COLUMNS, {
([Crash].[Weather].[Weather].ALLMEMBERS * [CrashPerson].[Person Injury
Class].[Person Injury Class].ALLMEMBERS ) } DIMENSION PROPERTIES
MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS FROM [SDMTest] CELL PROPERTIES
VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME,
FONT_SIZE, FONT_FLAGS
I just want to have the person injury classes, in seperate columns, instead
of the total of all of them together, that way when i put them in my table,
the user can see the (A-Injuries) fatal crashes (b-Injury) Fatal crashes...
and so on. And i dont have to have 15 different datasets with the same
fields and just one different Filter. It has to be possible.|||When it comes to MDX queries, you might get more help in the newsgroup
called microsoft.public.sqlserver.olap.
What are the names /hierarchies of the dimensions you want to return?
What measures do you want to see?
Do you want to see number of Fatal Injuries per weather?
From your example, it looks to me like you just want something like
SELECT { [Measures].[Fatal Crashes] } ON COLUMNS,
{
[CrashPerson].[Person Injury Class].[Person Injury Class].ALLMEMBERS
} DIMENSION PROPERTIES
MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS FROM [SDMTest]
Then you use a matrix, and create a column group for the CrashPerson field.
That should give you
..A-injury...|..B-injury..|..C-injury..|
..20.........|..20........|..10.........|
If you want to see injuries by weather and category, you can add the weather
dimension and create a row group for that.
Kaisa M. Lindahl Lervik
"Tenchy" <Tenchy@.discussions.microsoft.com> wrote in message
news:A8449F38-B807-4430-AF4C-10207DC3E5ED@.microsoft.com...
> Thats my problem, i dont know what the mdx code would be to do that.
> Because
> i can do mdx in reporting services in the dataset as a calculated member.
> But
> the code i put in there gives me all kinds of syntax errors. This is the
> code
> i have right now.
> SELECT { [Measures].[Vehicle Count], [Measures].[Injury Crashes],
> [Measures].[Non-Fatal Injuries], [Measures].[Fatal Injuries],
> [Measures].[CrashCount], [Measures].[Fatal Crashes] } ON COLUMNS, {
> ([Crash].[Weather].[Weather].ALLMEMBERS * [CrashPerson].[Person Injury
> Class].[Person Injury Class].ALLMEMBERS ) } DIMENSION PROPERTIES
> MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS FROM [SDMTest] CELL PROPERTIES
> VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME,
> FONT_SIZE, FONT_FLAGS
> I just want to have the person injury classes, in seperate columns,
> instead
> of the total of all of them together, that way when i put them in my
> table,
> the user can see the (A-Injuries) fatal crashes (b-Injury) Fatal
> crashes...
> and so on. And i dont have to have 15 different datasets with the same
> fields and just one different Filter. It has to be possible.

Calculated Member... Using case statment?!

Dear Friends,

I have a doubt that probably is to simple for you, but I'm a beginner in this subject and I need you.

how can I do a calculated member with case statment? I need to calculate the market value for factData based on each dimension...

DimInstrument InstrumentID InstrumentName 1 Bonds 2 Equities 3 Swaps ... ... 20 CreditSwaps

FactDados FactID InstrumentID AmountPos FxRate ... MarketValue 1 1 200.394,00 1 ... ... 2 2 776.000,00 1 ... ... 3 1 2.143.000,00 1,34 ... ... 4 18 546.560,00 1,34 ... ... 5 2 120.000,00 1 ... ... ... ... ... ... ... ... 123000 1 2.095.930,00 1 ... ...

For example the same calculated member, in the case of dimension is Bonds(1) the formula is one but when the dimension is Equities(2) the formula is diferent .

How can i do it? In the finally I only want the MarketValue (calculated member) for all the dimensions..

understood?

Thanks and regards!!

Hi,

Sure you can use case statement. Probably the best place to do it is a calculated memeber in dsv difinition of your fact table. This field should be calculated on a process step of your cube.

-Andrew

|||

Andy,

In SSAS you have Named Calculations is DSV and Calculater Members in the cube.

I want a calculated member and not named calculation because the formula is based on other calculated members that I dont have already in DSV, only in the cube...

So, what you told does not make sense, but thanks!!

|||Pedro,

Try this link - should help you plenty: http://technet.microsoft.com/en-us/library/ms144841.aspx

Rob|||Using SCOPE statements http://technet.microsoft.com/en-us/library/ms145989.aspx should provide better performance than using CASE. Custom Member formulas on the dimension members would be another option, it depends on the particular calculation as to which is the better option.|||Yeah - do what Darren suggests. He's an expert in MDX. But I'll restrain myself from advertising the user-group meeting that he's presenting at next week. Smile

Rob|||

Thanks All!!

Where is the Darren meeting group?

Regards!

|||

I'm speaking at the Adelaide SQL Server User Group next week (the one that Rob is President of )

http://www.sqlserver.org.au/events/ViewEvent.aspx?EventId=263

Calculated Member... Using case statment?!

Dear Friends,

I have a doubt that probably is to simple for you, but I'm a beginner in this subject and I need you.

how can I do a calculated member with case statment? I need to calculate the market value for factData based on each dimension...

DimInstrument InstrumentID InstrumentName 1 Bonds 2 Equities 3 Swaps ... ... 20 CreditSwaps

FactDados FactID InstrumentID AmountPos FxRate ... MarketValue 1 1 200.394,00 1 ... ... 2 2 776.000,00 1 ... ... 3 1 2.143.000,00 1,34 ... ... 4 18 546.560,00 1,34 ... ... 5 2 120.000,00 1 ... ... ... ... ... ... ... ... 123000 1 2.095.930,00 1 ... ...

For example the same calculated member, in the case of dimension is Bonds(1) the formula is one but when the dimension is Equities(2) the formula is diferent .

How can i do it? In the finally I only want the MarketValue (calculated member) for all the dimensions..

understood?

Thanks and regards!!

Hi,

Sure you can use case statement. Probably the best place to do it is a calculated memeber in dsv difinition of your fact table. This field should be calculated on a process step of your cube.

-Andrew

|||

Andy,

In SSAS you have Named Calculations is DSV and Calculater Members in the cube.

I want a calculated member and not named calculation because the formula is based on other calculated members that I dont have already in DSV, only in the cube...

So, what you told does not make sense, but thanks!!

|||Pedro,

Try this link - should help you plenty: http://technet.microsoft.com/en-us/library/ms144841.aspx

Rob|||Using SCOPE statements http://technet.microsoft.com/en-us/library/ms145989.aspx should provide better performance than using CASE. Custom Member formulas on the dimension members would be another option, it depends on the particular calculation as to which is the better option.|||Yeah - do what Darren suggests. He's an expert in MDX. But I'll restrain myself from advertising the user-group meeting that he's presenting at next week. Smile

Rob|||

Thanks All!!

Where is the Darren meeting group?

Regards!

|||

I'm speaking at the Adelaide SQL Server User Group next week (the one that Rob is President of )

http://www.sqlserver.org.au/events/ViewEvent.aspx?EventId=263

Calculated member wrong behaviour in Reporting Services

Hello,

I've created a SQL Server2005 AS Cube with a YTD calculated member:

Sum (YTD(),[Measures].[measure X])

This member (and others give the right results in the cube browser as well in an Excel pivot table). In a parameterized (year-month) report in Reporting services this does not work. It gives only the data of the given moth instead of the sum of all the months in the given year.

Can somebody help me with this issue?

Thanks!

Pieter

Hi Pieter,

What is the MDX query used in the report and what does your time dimension look like - I'm assuming that this problem occurs even with a fixed (no parameters) query?

|||

Thanx for your reply,

the YTD measures work correctly now both in the AS browser as in Reporting services, I redesigned the time dimension in AS. The only member whis does'nt work correctly in RS is a year total. this total works correct in the AS browser and also in RS without a parameter on time (month). It has to return the yeartotal regardless on what time is given in the parameter

The member looks as follows:

Measure Y:

sum(ancestors([Time dimension].[Hierarchy Year-Halfyear-Quarter-Month-Day].currentmember,[Time dimension].[Hierarchy Year-Halfyear-Quarter-Month-Day].[Year]),[Measures].[Measure X])

This is the MDX quert which is generated by RS:

SELECT NON EMPTY { [Measures].[Measure Y], [Measures].[Measure X] } ON COLUMNS FROM ( SELECT ( STRTOSET(@.Timedimensionhierarchyyearmonth, CONSTRAINED) ) ON COLUMNS FROM [ Cube]) WHERE ( IIF( STRTOSET(@.Timedimensionhierarchyyearmonth, CONSTRAINED).Count = 1, STRTOSET(@.Timedimensionhierarchyyearmonth, CONSTRAINED), [Time dimension].[Hierarchy year-month].currentmember ) ) CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS

Calculated member with measure and dimension

Hi,

We have a little problem with our calculated member... in our table we have the total amount of a sale in 2 different currencies (US and CAN).

In another field we have the currency (1 being can, 2 being US)

Now I need to create a measure that will give me all the amount in CAN money and one in US money (depending on how users want to view the cube) but it's not working since my Exchange rate is not a measure and the type of currency isn't either, so the system isn't entering in my case.

I tried to do something like this :

case [Probill General].[Payeur Fund type]

when 1

then ([Measures].[Probill Total] * [Probill General].[Us Exch Rate])

when 2

then ([Measures].[Probill Total])

end

But it doesn't enter in the cases and it gives me an empty data field when I put it in the cube.

Any idea on how to bypass that problem?

Thanks,

Jason

Hello. One problem with your Case statement is that you do no write this in the TSQL way.

Instead try something like:

Case When [Probill General].[Payeur Fund type] = 1

Then [Measures].[Probill Total] * [Probill General].[Us Exch Rate])

Else [Measures].[Probill Total]

End

A good Blog post about currency conversion you can find here: http://blogs.conchango.com/christianwade/archive/2006/08/24/Currency-Conversion-in-Analysis-Services-2005.aspx

HTH

Thomas Ivarsson

|||

Didn't work...

I went to that page and tried to create something based on that which didn't really solved my problem.

I think the real problem in my cube lies in the fact that my table has total that are both in canadian funds and us funds... all the solution on the web are to convert a full us fund (or other) to another currency but I can't seem to find anything where I can just transform or not an amount into a currency based on a dimension field...

I talked to my boss and she wants everything in Canadian funds, which means that IF my "[Probill General].[Payeur Fund type] = 1" then "[Measures].[Probill Total]" stays the same, but if it's "[Probill General].[Payeur Fund type] = 2" then it has to be "[Measures].[Probill Total] / [Probill General].[Us Exch Rate]" .

Any idea on how you can apply that in a cube?

Thanks

|||

With only two currencies the simple solution is to solve this problem in the ETL-process(not inte cube), when you load your data mart/data warehouse.

You will need a currency table with dates and currencies. If you have the currency code in the fact table when you load data, you join the date and the currency with your currency table.

If the requirement is that all values should be i CAD you only need to keep the exchange rate for CAD against your incoming currencies.

HTH

Thomas Ivarsson

Calculated member with measure and dimension

Hi,

We have a little problem with our calculated member... in our table we have the total amount of a sale in 2 different currencies (US and CAN).

In another field we have the currency (1 being can, 2 being US)

Now I need to create a measure that will give me all the amount in CAN money and one in US money (depending on how users want to view the cube) but it's not working since my Exchange rate is not a measure and the type of currency isn't either, so the system isn't entering in my case.

I tried to do something like this :

case [Probill General].[Payeur Fund type]

when 1

then ([Measures].[Probill Total] * [Probill General].[Us Exch Rate])

when 2

then ([Measures].[Probill Total])

end

But it doesn't enter in the cases and it gives me an empty data field when I put it in the cube.

Any idea on how to bypass that problem?

Thanks,

Jason

Hello. One problem with your Case statement is that you do no write this in the TSQL way.

Instead try something like:

Case When [Probill General].[Payeur Fund type] = 1

Then [Measures].[Probill Total] * [Probill General].[Us Exch Rate])

Else [Measures].[Probill Total]

End

A good Blog post about currency conversion you can find here: http://blogs.conchango.com/christianwade/archive/2006/08/24/Currency-Conversion-in-Analysis-Services-2005.aspx

HTH

Thomas Ivarsson

|||

Didn't work...

I went to that page and tried to create something based on that which didn't really solved my problem.

I think the real problem in my cube lies in the fact that my table has total that are both in canadian funds and us funds... all the solution on the web are to convert a full us fund (or other) to another currency but I can't seem to find anything where I can just transform or not an amount into a currency based on a dimension field...

I talked to my boss and she wants everything in Canadian funds, which means that IF my "[Probill General].[Payeur Fund type] = 1" then "[Measures].[Probill Total]" stays the same, but if it's "[Probill General].[Payeur Fund type] = 2" then it has to be "[Measures].[Probill Total] / [Probill General].[Us Exch Rate]" .

Any idea on how you can apply that in a cube?

Thanks

|||

With only two currencies the simple solution is to solve this problem in the ETL-process(not inte cube), when you load your data mart/data warehouse.

You will need a currency table with dates and currencies. If you have the currency code in the fact table when you load data, you join the date and the currency with your currency table.

If the requirement is that all values should be i CAD you only need to keep the exchange rate for CAD against your incoming currencies.

HTH

Thomas Ivarsson

Calculated Member using CurrentMember.Properties("XX") does not work for ALL Level on

IIF (

[HAP5All_Board].CurrentMember.Properties("Dept") = "PH",

(

[BoardIncAcct2].&[61510000] -- General Services

+

[BoardIncAcct2].&[61520000] -- Accounting & Financem Services

+

[BoardIncAcct2].&[61530000] -- Information Technology Services

+

[BoardIncAcct2].&[61540000] -- Purchaseing Services

+

[BoardIncAcct2].&[61550000] -- Executive Services

+

[BoardIncAcct2].&[61560000] -- Human Resources Services

+

[BoardIncAcct2].&[61570000] -- Public Affairs Services

+

[BoardIncAcct2].&[61580000] -- Training Services

)

,

0

) -- IIF Section to filter in only PH

This is in the definition of a calculated member. It works fine for all members except for the "ALL level" on the dimension (Parent-Child dimension). Because the "All Level" is not actually a member/record in the table but defined on the dimension, it does not have Properties for that particular "member", so AS errors out when trying to focus on top ALL Level. What should we do to use such definition on ALL Level?

Maybe you could check for the [All] member first, like:

IIF (

[HAP5All_Board].CurrentMember is [HAP5All_Board].[All],

0,

IIF (

[HAP5All_Board].CurrentMember.Properties("Dept") = "PH",

(

[BoardIncAcct2].&[61510000] -- General Services

+

[BoardIncAcct2].&[61520000] -- Accounting & Financem Services

+

[BoardIncAcct2].&[61530000] -- Information Technology Services

+

[BoardIncAcct2].&[61540000] -- Purchaseing Services

+

[BoardIncAcct2].&[61550000] -- Executive Services

+

[BoardIncAcct2].&[61560000] -- Human Resources Services

+

[BoardIncAcct2].&[61570000] -- Public Affairs Services

+

[BoardIncAcct2].&[61580000] -- Training Services

)

,

0

) -- IIF Section to filter in only PH

)

|||

Thanks, Deepak!

That works syntactically. OLAP took it. However, I am wondering that ALL level is taking the aggregate sumation of all children, would that (IF ALL THEN 0) rules out children that actually is PH in Properties. Or in other words, I need to have PH and all others roll up into ALL with PH children having those accounts incluced. Would (IFF ALL THEN 0) prevent PH children to be correctly rolled up? Am I making sense?

Thanks again!

Julius

|||

Hi Julius,

Could you illustrate your exact scenario with some examples - I have only a vague idea of what you want, since 2 different dimensions seem to be involved?