• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1131
  • Last Modified:

Dynamic MDX problem in SSRS2005

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
JekaCh
Asked:
JekaCh
  • 2
  • 2
1 Solution
 
Tim HumphriesCommented:
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
 
JekaChAuthor Commented:
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
 
Tim HumphriesCommented:
0
 
JekaChAuthor Commented:
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now