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

Monday, March 26, 2012

How to apply an MDX filter that doesn't affect roll-up?

Take the Employee dimension of Adventure Works Cube. I want to see a list of all Male Employees and the total Reseller-Sales they supervise. My MDX query looks like this

Select [Measures].[Reseller Sales-Sales Amount] on Columns,
non empty [Employee].[Employees].AllMembers on Rows
from [Analysis Services Tutorial]
where [Employee].[Gender].&[M]

and I get a result of

Reseller Sales-Sales Amount
All Employees $44,244,815.17
Ken J. Sánchez $44,244,815.17
Brian S. Welcker $44,244,815.17
Ranjit R. Varkey Chudukatil $4,509,888.93
Stephen Y. Jiang $39,562,401.78
David R. Campbell $3,729,945.35
Garrett R. Vargas $3,609,447.22
Jos Edvaldo. Saraiva $5,926,418.36
Michael G. Blythe $9,293,903.01
Shu K. Ito $6,427,005.56
Stephen Y. Jiang $1,092,123.86
Tete A. Mensa-Annan $2,312,545.69
Tsvi Michael. Reiter $7,171,012.75
Syed E. Abbas $172,524.45

ok so it gave me all the male employees, which is good, but the sales amounts are incorrect, it is only summing

the sales of the male underlings. Ken J. Sánchez actually has 80 million in sales under him, Stephen Y. Jiang has 63 million, etc... The Cube is not counting the female underlings sales. How do I include everything in the roll-ups, but only return the male supervisors?

Thanks

Todd Wilder

Select [Measures].[Reseller Sales-Sales Amount] on Columns,
non empty

Exists(

[Employee].[Employees].AllMembers

,[Employee].[Gender].&[M]

) on Rows
from [Analysis Services Tutorial]

That should only show male employees on rows, but the totals should reflect all employees under them.|||

There seems to be a slight twist to this, since Employee is a parent-child dimension. Apparently, using the parent-child hierarchy, a member can "exist" with an attribute like [Employee].[Gender].&[M] if any of its descendants are male. But a member of the key attribute hierarchy works as with regular dimensions. So LinkMember() can be used to map key attribute members to the corresponding parent-child members, like:

Select [Measures].[Reseller Sales Amount] on Columns,
non empty Generate(exists([Employee].[Employee].[Employee],
[Employee].[Gender].&[M]),
{LinkMember([Employee].[Employee].CurrentMember,
[Employee].[Employees])}) on Rows
from [Adventure Works]

In this case, there is a discrepancy between the 2 queries of a single (non empty) member - Amy E. Alberts (female):

Select [Measures].[Reseller Sales Amount] on Columns,
non empty exists([Employee].[Employees].Members,
[Employee].[Gender].&[M]) -
Generate(exists([Employee].[Employee].[Employee],
[Employee].[Gender].&[M]),
{LinkMember([Employee].[Employee].CurrentMember,
[Employee].[Employees])})on Rows
from [Adventure Works]
--
Reseller Sales Amount
All Employees $80,450,596.98
Amy E. Alberts $15,535,946.26

Friday, March 23, 2012

How to allow normal user (not Administrator) deployment of SSAS Cube?

Hello,

how to allow normal user (not Administrator) deployment of SSAS Cube? It says always that normal user cannot create new objects.

Andrey.

In order to create a database you need to be an Analysis Server admin.

In order to create cubes, dimensions, partitions you need to be database administrator.

Edward.
--
This posting is provided "AS IS" with no warranties, and confers no rights.

|||

If you want your user to work with a BI project (that he will edit in Visual Studio and then deploy), these are the things to do:

- you need to create the database yourself (empty database) as server admin

- you need to give user admin rights for the database (using SQL Management Studio, create a Role)

- then user can deploy the BI project. Important: his project needs to contain the Role definition specifying him as admin (otherwise when he deploys the project, he will cut his access). To ensure you have the Role definition, you could initially create the BI project out of the live empty database (from VS, chose New Project, Import Analysis Services 9.0 Database wizard; then make sure that the newly create BI project specifies in its properties your database name).

Adrian Dumitrascu.

|||

I created a Cube from my DataWarehouse.
Under Administrator account I can deploy the Cube and everything is fine.
Then I want to allow normal user (programmer) to develop and deploy it in Business Intelligence Development Studio. This user has no Administrator rights.
So, I receive something like "User _xxx_ has no rights to change _yyy_-objects or an object does not exist" (my translation from German).

Granting user all rights to the DataWarehouse, creating Role in SQL Management Studio for DataWarehouse does not help. What really helps: creating Administrator Role for user in SSAS project and deploying project to Analysis Service under Administrator! So, this role will be uploaded to the service. After this, service recognizes user as an Administrator!
If you try to deploy project for the first time under user, then the role will not be uploaded (no rights). If you try to create role in SQL Management Studio instead of in BI project, then user will update service, remove role from service (since there is no role in project) and after this will be non-recognizeable.
It is possible also to create role in SQL Management Studio and then identical role in BI project. And then user can deploy.

Thanks for help! It gave a clue :)

Wednesday, March 21, 2012

How to address cells in a calculation

I have a calculation where I need to get the value of a certain cell in my cube. It looks like this:

([Measures].[Amount],

[Table].[Table].&[{327365F8-F148-4C34-A749-D3F56FD3B8F6}],

[Line].[Line].&[{2155F898-47EA-4269-B167-BE940C79E9F6}],

[Column].[Column].&[{83435F85-93AB-48D1-B2F3-B5E0BAF62642}],

[Currency].[Currency].&[{2FA606E1-0A20-4A21-B360-643A530C297B}],

[Maturity].[Maturity].&[{188601ED-2E02-4883-9336-45BC831C5EE8}],

[Region].[Region].&[{0712BAAF-FEE4-479E-8287-E75DAD405B40}],

[Sector].[Sector].&[{E52C493D-6528-490E-BD63-4A0857F8B53F}],

[PastDue].[PastDue].&[{524942A0-A1ED-4BF5-86D2-F8EF393F0004}],

[Custom].[Custom].&[{7FCAB9D1-4D7B-48CD-8EEC-1AA47F5D9CD1}],

[Situation].[Situation].&[{7187DCEE-11C9-4EC2-A2CB-BC2534716D8B}])

The problem here are the uniqueidentifiers or as you like the ID's of the members. Is there another way to select a certain cell in my cube by using other properties of the members ? I would prefer something like

(

[Measures].[Amount],

[Table].[Table].&["First Table"],

[Line].[Line].&["First Line"],

[Column].[Column].&["First Column"],

[Currency].[Currency].&["EUR"],

[Maturity].[Maturity].&["TotalMaturity"],

[Region].[Region].&["TotalRegion"],

[Sector].[Sector].&["TotalSector"],

[PastDue].[PastDue].&["TotalPastDue"],

[Custom].[Custom].&["TotalCustom"],

[Situation].[Situation].&["TotalSituation"]

)

When referencing a member you can use the "Key" value or the "Name" value. In your example:

This referes to a "Key" value

[Currency].[Currency].&[{2FA606E1-0A20-4A21-B360-643A530C297B}],

You can refer to the "Name" value using:

[Currency].[Currency].[EUR],

Notice that the "&" symbol is removed when referencing a member name.

HTH,

- Steve

|||

Absolutely.

You can use names instead of the keys.
In the simpliest case you just to drop the "&" character and make sure you provide a full path to your member.

In form of :

[Dimension].[Hierarchy].[Level].[Member]

For instance ; [Product].[Products].[Product Family].[Drink]

Edward.
--
This posting is provided "AS IS" with no warranties, and confers no rights.

|||

Thank you both for your answer.

I have a dimension where multiple members have the same name ... how can I address these ?

thanx in advance

|||

Answer is that it depends.

If you have two members with the same parent then:

[Dimension].[Hierarchy].[Parent Level Name].[Parent Member Name].[Member Name]

will return the value for the first member matching the "Member Name"

If the two members have different parents then:

[Dimension].[Hierarchy].[Parent Level Name].[Parent Member Name 1].[Member Name]

[Dimension].[Hierarchy].[Parent Level Name].[Parent Member Name 2].[Member Name]

can be used to reference each member individually.

HTH,

Steve

Friday, March 9, 2012

How to add filter based on query?

Hi guys,

I have the following problem:
I have several tables in SQL 2005 ( table GeographicLocations and other related to it ). I created a cube in SSAS in which GeographicLocations is dimension.

I was able to add parameters but I need something more complicated: Having columns longitude and latitude in GeographicLocations I need to be able to return all locations within X (parameter) miles from passed GeographicLocation (parameter - GeographicLocationID )

I found SQL function that calculates distance from passed longitude and latitude of two points and T-SQL would like this:

declare @.GeoId int;
set @.GeoID = 200765;

select * from GeographicLocations as t1
where dbo.geo_distance(t1.longitude, t1.latitude,
(select longitude from GeographicLocations where id=@.GeoID),
(select latitude from GeographicLocations where id=@.GeoID)) < 2000

but how I can make same in SSAS and Reports?

Thanks in advance

I suggest making Longitude and Latitude related attributes of GeoLocation, and then implement SSAS sproc which computes difference between two points (similar to geo_distance).

|||

Hi Mosha,

Thank you very much for helping me.

I would like to ask you to be more specific as I am newbee in SSAS. Could you point me at some samples and resources that use such approach?

It is kind of blury to me how to create related attributes in such manner (although I read this article ), how to create SSAS stored procedure and how to call it from the report project

Best regards,

Galin

|||

Hi,

Any advise ? I'm dealing with the same problem and I'm also a newbie in SSAS.

I was thinking to make an user defined function in an assembly to compute the distance but I can't figure out if this will be viable.

Daniel.

|||I made .NET function to calculate distance - same as T-SQL one

also I made Longitude and Latitude measures and I could pass them in MDX query

Hope this helps|||

Hi,

Can you provide a sample of your MDX query ?

I was thinking that Lat and Long to be dimensions not measures.

Thnx.

daniel

|||

I've changed the fact table in order to have Latitude and Longitude as Measures; so now I have:

Measures(AggregateFunction)

PriceCount (Count),

Latitude (None),

Longitude (None)

Dimension

[Tbl DW Dim Property Type]

but from tests I've found that performing filter operations on Latitude/Longitude measures it is returning wrong results:

Code Snippet

SELECT

NON EMPTY { [Measures].[Prices Count] } ON COLUMNS,

NON EMPTY FILTER([Tbl DW Dim Property Type].[Name].Members, [Measures].[Latitude]>44.42659335504373) ON ROWS

FROM [DW DEV]

so I used an .NET sp to capture the data:

Code Snippet

SELECT

NON EMPTY { [Measures].[Prices Count] } ON COLUMNS,

NON EMPTY FILTER([Tbl DW Dim Property Type].[Name].Members, MDXClassLibrary.DoSomething([Measures].[Latitude])>44.42659335504373) ON ROWS

FROM [DW DEV]

Code Snippet

public static double DoSomething(double x)

{

return x;

}

And during debugging I’ve found that the sp’s parameter is receiving wrong values not the ones that are in [Measures].[Latitude].

I know that I'm missing something but I can't figure.

Any help would be appreciated.

|||

I've managed to run a query like this

Code Snippet

SELECT NON EMPTY { [Measures].[Prices Avg], [Measures].[Prices Max], [Measures].[Prices Min] } ON COLUMNS,

NON EMPTY { ([Tbl DW Dim Time].[Calendar Year].[Calendar Year].ALLMEMBERS *

[Tbl DW Dim Time].[Month Number Of Year].[Month Number Of Year].ALLMEMBERS ) }

DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS

FROM

( SELECT ( { FILTER([Tbl DW Dim Gis].[Coord].MEMBERS,

mdxclasslibrary.dist([Tbl DW Dim Gis].[Coord].CurrentMember.Name,

'44.42366640719915000000000','26.07366800308228000000000',1 )>0)}) ON COLUMNS

FROM (

SELECT ({[Tbl DW Dim Property Type].[Name].&[Apartment] } ) ON COLUMNS

FROM [DEV]))

but i noticed a significant performance degradation.

Any suggestions ?

How to add filter based on query?

Hi guys,

I have the following problem:
I have several tables in SQL 2005 ( table GeographicLocations and other related to it ). I created a cube in SSAS in which GeographicLocations is dimension.

I was able to add parameters but I need something more complicated: Having columns longitude and latitude in GeographicLocations I need to be able to return all locations within X (parameter) miles from passed GeographicLocation (parameter - GeographicLocationID )

I found SQL function that calculates distance from passed longitude and latitude of two points and T-SQL would like this:

declare @.GeoId int;
set @.GeoID = 200765;

select * from GeographicLocations as t1
where dbo.geo_distance(t1.longitude, t1.latitude,
(select longitude from GeographicLocations where id=@.GeoID),
(select latitude from GeographicLocations where id=@.GeoID)) < 2000

but how I can make same in SSAS and Reports?

Thanks in advance

I suggest making Longitude and Latitude related attributes of GeoLocation, and then implement SSAS sproc which computes difference between two points (similar to geo_distance).

|||

Hi Mosha,

Thank you very much for helping me.

I would like to ask you to be more specific as I am newbee in SSAS. Could you point me at some samples and resources that use such approach?

It is kind of blury to me how to create related attributes in such manner (although I read this article ), how to create SSAS stored procedure and how to call it from the report project

Best regards,

Galin

|||

Hi,

Any advise ? I'm dealing with the same problem and I'm also a newbie in SSAS.

I was thinking to make an user defined function in an assembly to compute the distance but I can't figure out if this will be viable.

Daniel.

|||I made .NET function to calculate distance - same as T-SQL one

also I made Longitude and Latitude measures and I could pass them in MDX query

Hope this helps|||

Hi,

Can you provide a sample of your MDX query ?

I was thinking that Lat and Long to be dimensions not measures.

Thnx.

daniel

|||

I've changed the fact table in order to have Latitude and Longitude as Measures; so now I have:

Measures(AggregateFunction)

PriceCount (Count),

Latitude (None),

Longitude (None)

Dimension

[Tbl DW Dim Property Type]

but from tests I've found that performing filter operations on Latitude/Longitude measures it is returning wrong results:

Code Snippet

SELECT

NON EMPTY { [Measures].[Prices Count] } ON COLUMNS,

NON EMPTY FILTER([Tbl DW Dim Property Type].[Name].Members, [Measures].[Latitude]>44.42659335504373) ON ROWS

FROM [DW DEV]

so I used an .NET sp to capture the data:

Code Snippet

SELECT

NON EMPTY { [Measures].[Prices Count] } ON COLUMNS,

NON EMPTY FILTER([Tbl DW Dim Property Type].[Name].Members, MDXClassLibrary.DoSomething([Measures].[Latitude])>44.42659335504373) ON ROWS

FROM [DW DEV]

Code Snippet

public static double DoSomething(double x)

{

return x;

}

And during debugging I’ve found that the sp’s parameter is receiving wrong values not the ones that are in [Measures].[Latitude].

I know that I'm missing something but I can't figure.

Any help would be appreciated.

|||

I've managed to run a query like this

Code Snippet

SELECT NON EMPTY { [Measures].[Prices Avg], [Measures].[Prices Max], [Measures].[Prices Min] } ON COLUMNS,

NON EMPTY { ([Tbl DW Dim Time].[Calendar Year].[Calendar Year].ALLMEMBERS *

[Tbl DW Dim Time].[Month Number Of Year].[Month Number Of Year].ALLMEMBERS ) }

DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS

FROM

( SELECT ( { FILTER([Tbl DW Dim Gis].[Coord].MEMBERS,

mdxclasslibrary.dist([Tbl DW Dim Gis].[Coord].CurrentMember.Name,

'44.42366640719915000000000','26.07366800308228000000000',1 )>0)}) ON COLUMNS

FROM (

SELECT ({[Tbl DW Dim Property Type].[Name].&[Apartment] } ) ON COLUMNS

FROM [DEV]))

but i noticed a significant performance degradation.

Any suggestions ?

How to add filter based on query?

Hi guys,

I have the following problem:
I have several tables in SQL 2005 ( table GeographicLocations and other related to it ). I created a cube in SSAS in which GeographicLocations is dimension.

I was able to add parameters but I need something more complicated: Having columns longitude and latitude in GeographicLocations I need to be able to return all locations within X (parameter) miles from passed GeographicLocation (parameter - GeographicLocationID )

I found SQL function that calculates distance from passed longitude and latitude of two points and T-SQL would like this:

declare @.GeoId int;
set @.GeoID = 200765;

select * from GeographicLocations as t1
where dbo.geo_distance(t1.longitude, t1.latitude,
(select longitude from GeographicLocations where id=@.GeoID),
(select latitude from GeographicLocations where id=@.GeoID)) < 2000

but how I can make same in SSAS and Reports?

Thanks in advance

I suggest making Longitude and Latitude related attributes of GeoLocation, and then implement SSAS sproc which computes difference between two points (similar to geo_distance).

|||

Hi Mosha,

Thank you very much for helping me.

I would like to ask you to be more specific as I am newbee in SSAS. Could you point me at some samples and resources that use such approach?

It is kind of blury to me how to create related attributes in such manner (although I read this article ), how to create SSAS stored procedure and how to call it from the report project

Best regards,

Galin

|||

Hi,

Any advise ? I'm dealing with the same problem and I'm also a newbie in SSAS.

I was thinking to make an user defined function in an assembly to compute the distance but I can't figure out if this will be viable.

Daniel.

|||I made .NET function to calculate distance - same as T-SQL one

also I made Longitude and Latitude measures and I could pass them in MDX query

Hope this helps|||

Hi,

Can you provide a sample of your MDX query ?

I was thinking that Lat and Long to be dimensions not measures.

Thnx.

daniel

|||

I've changed the fact table in order to have Latitude and Longitude as Measures; so now I have:

Measures(AggregateFunction)

PriceCount (Count),

Latitude (None),

Longitude (None)

Dimension

[Tbl DW Dim Property Type]

but from tests I've found that performing filter operations on Latitude/Longitude measures it is returning wrong results:

Code Snippet

SELECT

NON EMPTY { [Measures].[Prices Count] } ON COLUMNS,

NON EMPTY FILTER([Tbl DW Dim Property Type].[Name].Members, [Measures].[Latitude]>44.42659335504373) ON ROWS

FROM [DW DEV]

so I used an .NET sp to capture the data:

Code Snippet

SELECT

NON EMPTY { [Measures].[Prices Count] } ON COLUMNS,

NON EMPTY FILTER([Tbl DW Dim Property Type].[Name].Members, MDXClassLibrary.DoSomething([Measures].[Latitude])>44.42659335504373) ON ROWS

FROM [DW DEV]

Code Snippet

public static double DoSomething(double x)

{

return x;

}

And during debugging I’ve found that the sp’s parameter is receiving wrong values not the ones that are in [Measures].[Latitude].

I know that I'm missing something but I can't figure.

Any help would be appreciated.

|||

I've managed to run a query like this

Code Snippet

SELECT NON EMPTY { [Measures].[Prices Avg], [Measures].[Prices Max], [Measures].[Prices Min] } ON COLUMNS,

NON EMPTY { ([Tbl DW Dim Time].[Calendar Year].[Calendar Year].ALLMEMBERS *

[Tbl DW Dim Time].[Month Number Of Year].[Month Number Of Year].ALLMEMBERS ) }

DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS

FROM

( SELECT ( { FILTER([Tbl DW Dim Gis].[Coord].MEMBERS,

mdxclasslibrary.dist([Tbl DW Dim Gis].[Coord].CurrentMember.Name,

'44.42366640719915000000000','26.07366800308228000000000',1 )>0)}) ON COLUMNS

FROM (

SELECT ({[Tbl DW Dim Property Type].[Name].&[Apartment] } ) ON COLUMNS

FROM [DEV]))

but i noticed a significant performance degradation.

Any suggestions ?

How to add calculated Facts in Measure Group

hi,

I am new to SSAS. i am working up on cube. I want to add calculated fact in the cube.

like... Suppose we have fact table in which we have fields like (ID, Status)

and status can have 3 values (1,2 ,3) . My requirement is Count of rows having Status 1 + Count of rows having status 2.

How to accomplish this task.

Additionally if dimension is required suppose i have Status(statusID) dimension also.

Please provide me urgent solution!

Thanks in advance.

Mandip

Hi Mandip,

before I start I beg for pardon, because I am working on a German version of SSAS.

You can put two new named calculations in Your datasource view.

First.

CASE WHEN Status = 1 THEN 1 ELSE NULL END

(suggested columnname Stat1)

Second:

CASE WHEN Status = 2 THEN 1 ELSE NULL END

(suggested columnsname Stat2)

Now You can use these two new columns as new measures (count or sum).

cheers

B.

|||

Thanks very much!

I know if the status entries are going to be static this would work.

but in my case at anytime in future we can have new status suppose (4)...

then can there any other method by which i need not to add new columns in fact table... and still i can be able to take calculated fact? Means i don't want to change design structure of cube.

Mandip

|||In the situation you describe, status should be implemented as a dimension. As a rule of thumb any time you want to report amounts "by" something, it is a good indicator that you should implement it as a dimension.

Friday, February 24, 2012

How to Add a Calculated Column in Report Builder using a Model Based on a SSAS Cube

I am trying to add a calculated field / column in Report Builder when working with a Report Model built from anAnalysis Services Cube. I can create the calculated Field/Columns, but I get an error whenever I try to use it in a report.

Is there a way to create a report builder calculated column on report models built from a SSAS cube? Is this supported?

Thanks,

Some functions are not supported for calculated fields when running against an SSAS cube, in particular the aggregate functions like Sum, Count, Average, etc. The error message should provide some details on this.

Hope that helps!

|||

The support for calculated fields in an SSAS model is better than Bob lets on. Most functions work. The trick is that you need to install Excel 2003 on the Analysis Services server. (Not sure if other versions like Excel 2007 work, but I know Excel 2003 does the trick.)

Report Builder builds MDX that use Excel functions, and for those functions to succeed, Excel has to be installed on the server.

If you agree with me that this is a terrible architecture, vote for this issue:

https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=124864

|||Are there any online documentation about this? Our IT policy is not to install office or office application on SQL Server boxes.|||

Common policy. Vote for that issue at connect.microsoft.com and maybe MS will change this in Katmai.

As for documentation:

http://msdn2.microsoft.com/en-us/library/ms145486.aspx

And documentation of the excel functions that are supported. (Don't know if there's a 2005 version of this page, but they're the same):

http://msdn2.microsoft.com/en-us/library/aa178231(SQL.80).aspx

I suppose one workaround is to code the Excel functions yourself and register them as specified here:

http://geekswithblogs.net/darrengosbell/archive/2006/12/13/100998.aspx

If you have interest in going that route, let me know because there are some gotchas.

How to Add a Calculated Column in Report Builder using a Model Based on a SSAS Cube

I am trying to add a calculated field / column in Report Builder when working with a Report Model built from anAnalysis Services Cube. I can create the calculated Field/Columns, but I get an error whenever I try to use it in a report.

Is there a way to create a report builder calculated column on report models built from a SSAS cube? Is this supported?

Thanks,

Some functions are not supported for calculated fields when running against an SSAS cube, in particular the aggregate functions like Sum, Count, Average, etc. The error message should provide some details on this.

Hope that helps!

|||

The support for calculated fields in an SSAS model is better than Bob lets on. Most functions work. The trick is that you need to install Excel 2003 on the Analysis Services server. (Not sure if other versions like Excel 2007 work, but I know Excel 2003 does the trick.)

Report Builder builds MDX that use Excel functions, and for those functions to succeed, Excel has to be installed on the server.

If you agree with me that this is a terrible architecture, vote for this issue:

https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=124864

|||Are there any online documentation about this? Our IT policy is not to install office or office application on SQL Server boxes.|||

Common policy. Vote for that issue at connect.microsoft.com and maybe MS will change this in Katmai.

As for documentation:

http://msdn2.microsoft.com/en-us/library/ms145486.aspx

And documentation of the excel functions that are supported. (Don't know if there's a 2005 version of this page, but they're the same):

http://msdn2.microsoft.com/en-us/library/aa178231(SQL.80).aspx

I suppose one workaround is to code the Excel functions yourself and register them as specified here:

http://geekswithblogs.net/darrengosbell/archive/2006/12/13/100998.aspx

If you have interest in going that route, let me know because there are some gotchas.