Solved

Dynamic MDX problem in SSRS2005

Posted on 2010-09-01
4
1,103 Views
Last Modified: 2016-02-15
I have the following problem: I need to create dynamic mdx query to SSAS 2005 in SSRS 2005.
I'am creating dynamic mdx query with the help of embedded code ant it's ok. The code returns three dimensions and two measure columns. These three dimensions are being genenerated in my code dynamically. The problems begin when I need to assign column name in dataset. I can't make alias for returning dimensions like in SQL (select column as 'aaa'). I've tried to generate column name in dataset dynamically but unfortunately it didn't work.
Value for field assign in SSRS dataset for OLAP source loks like: <?xml version="1.0" encoding="utf-8"?><Field xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="Level" UniqueName="[Dim Dimension].[Dimension]" />. If i generate it in code and assign in dataset it doesn't work.
Another decision which I tried is to generate these columns through the following code:
with member Measures.RowGroup1 as [Dim Dimension1].[Dimension1].CurrentMember.Member_Caption
member Measures.RowGroup2 as [Dim Dimension2].[Dimension2].CurrentMember.Member_Caption
member Measures.RowGroup3 as [Dim Dimension3].[Dimension3].CurrentMember.Member_Caption
SELECT non empty
 {
      Measures.RowGroup1,
      Measures.RowGroup2,
      Measures.RowGroup3,
      [Measures].[Num]
      , [Measures].[Amt]
} ON COLUMNS
, non empty
(
      [Dim Dimension1].[Dimension1].[Dimension1].MEMBERS
      ,[Dim Dimension2].[Dimension2].[Dimension2].MEMBERS
      ,[Dim Dimension3].[Dimension3].[Dimension3].MEMBERS
  ) ON ROWS  .
When I use it for one dimension it's ok, but using all these measures together make mdx query running forever.
Does anyone know any solution for this problem?
0
Comment
Question by:JekaCh
  • 2
  • 2
4 Comments
 
LVL 15

Expert Comment

by:Tim Humphries
ID: 33577699
Hi,

Are you generating a matrix report? If not, then rather than trying to return the column names in the query, can you not use similar logic to that used to build the query to dynamically change the column header names in the report layout?

So in your column headers you would call a function =Code.GetFirstColumnName etc.
I don't think you'll get far trying to get the column names back dynamically in your MDX, unless you used a third party tool such as Intelligencia maybe, but that costs £

Tim
0
 

Author Comment

by:JekaCh
ID: 33579285
Thanks for your comment, but the problem is not in creating column names in matrix report layout but in creating column definitions in dataset. Because as I described above in SSRS I unfortunately have to set  each column returning by query its name. And for OLAP source it seems can't be generated in code.
0
 
LVL 15

Accepted Solution

by:
Tim Humphries earned 500 total points
ID: 33582328
0
 

Author Comment

by:JekaCh
ID: 33590352
Thank you Tim this solution helped but I've earned new security problems because is seems that only user in sysadmin role could execute openrowset queries. Th following link helped me to solve this problem:
http://www.kodyaz.com/articles/enable-Ad-Hoc-Distributed-Queries.aspx
http://support.microsoft.com/kb/328569 - it works not just for SQL Server 2000 but for at least 2005 too.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Creating and Managing Databases with phpMyAdmin in cPanel.
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now