|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Monday, June 20, 2011 9:06 AM
Points: 2,
Visits: 12
|
|
Assuming that I have multiple cubes I am reading from SQL Server Analysis Services.
All my cubes have the same names.
Is the way I can create a report that spans across multiple cubes or merge all the cubes' calculations.
Thanks,
Ron
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Friday, December 02, 2011 12:11 AM
Points: 125,
Visits: 77
|
|
Hi Ron,
you can use the approach shown in this article to create a report which gets its content from more than one cubes:
For example you have one mdx which retrieves the number of invoices per customer. You can write the results into a temp-table with the technique shown in the article. Then you have another mdx from another cube (which then is another linked server) which gets the number of visits on your homepage per customer. Write this into another temp-table.
Then you can (inner/outer) join these tables as you like (now we are in normal SQL environment again, where we can do whatever we like with the data).
If the cubes are in the same database, have a look at the lookupcube-mdx function (s. http://msdn.microsoft.com/en-us/library/ms144720.aspx). This also could solve your problem.
Hope that helped.
Martin
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Thursday, April 18, 2013 1:24 AM
Points: 178,
Visits: 261
|
|
Thanks, nice article.
I have one issue of my own though and can't find a way around it. I have 3 mdx statements I am joining using openquery, setting a variable and then using sp_executesql to run it. The problem I have is when say the third join is empty, the whole thing comes back as empty. I am setting values on the fly (there are far more vatriables than posted here) and therefore can not simply execute with OPENQUERY into a #temp table and then check for existance of the columns (I am seriously starting to fall out with OPENQUERY).
What I need is if there are no results from the third query, to still return the National and Regional results (there are still results) without having to re-execute the whole thing in a nested try/catch. Can anyone think of a novel way to do this as hitting major walls at the moment?
SET @SQL = 'SELECT Series , RegionName , OrgName , NationalTurn , CONVERT(DECIMAL(18,2),NationalPercent * 100.0000) AS NationalPercent , RegionalTurn , CONVERT(DECIMAL(18,2),RegionalPercent * 100.0000) AS RegionalPercent , DLRTurn , CONVERT(DECIMAL(18,2),DLRPercent * 100.0000) AS DLRPercent FROM ( SELECT CONVERT(VARCHAR,NationalTurn."[ModelDesc].[Series].[Series].[MEMBER_CAPTION]") AS Series , CONVERT(VARCHAR,RegionalTurn."[DealerInformation].[Region Name].[Region Name].[MEMBER_CAPTION]") AS RegionName , CONVERT(VARCHAR,DLRTurn."[DealerInformation].[Organisation Name].[Organisation Name].[MEMBER_CAPTION]") AS OrgName , CAST(CONVERT(FLOAT,NationalTurn."[Measures].[Turn(Months)]") AS DECIMAL(18,2) ) AS NationalTurn , CAST(CONVERT(FLOAT,NationalTurn."[Measures].[NationalMixPercent]") AS DECIMAL(18,5) ) AS NationalPercent , CAST(CONVERT(FLOAT,RegionalTurn."[Measures].[Turn(Months)]") AS DECIMAL(18,2) ) AS RegionalTurn , CAST(CONVERT(FLOAT,RegionalTurn."[Measures].[RegionalMixPercent]") AS DECIMAL(18,5) ) AS RegionalPercent , CAST(CONVERT(FLOAT,DLRTurn."[Measures].[Turn(Months)]") AS DECIMAL(18,2) ) AS DLRTurn , CAST(CONVERT(FLOAT,DLRTurn."[Measures].[DLRMixPercent]") AS DECIMAL(18,5) ) AS DLRPercent FROM OPENQUERY(MSOLAPSRV,''SELECT { [Measures].[Turn(Months)] , [Measures].[NationalMixPercent] } ON COLUMNS , NONEMPTY( { ([ModelDesc].[Series].[' + @Series + '] ) }, { [Measures].[Turn(Months)] , [Measures].[NationalMixPercent] }) ON ROWS FROM [cube] WHERE ([StockApplication].[PWD App ID].[' + @AppID + ']) '' ) NationalTurn INNER JOIN OPENQUERY(MSOLAPSRV,''SELECT { [Measures].[Turn(Months)] , [Measures].[RegionalMixPercent] } ON COLUMNS , NONEMPTY( { ([ModelDesc].[Series].[' + @Series + '] , [DealerInformation].[Region Name].[' + @Region + ']) } , { [Measures].[Turn(Months)] , [Measures].[RegionalMixPercent] }) ON ROWS FROM [cube] WHERE ([StockApplication].[PWD App ID].[' + @AppID + ']) '' ) RegionalTurn ON CONVERT(VARCHAR,NationalTurn."[ModelDesc].[Series].[Series].[MEMBER_CAPTION]") = CONVERT(VARCHAR,RegionalTurn."[ModelDesc].[Series].[Series].[MEMBER_CAPTION]") INNER JOIN OPENQUERY(MSOLAPSRV,''SELECT { [Measures].[Turn(Months)] , [Measures].[DLRMixPercent] } ON COLUMNS , NONEMPTY( { ([ModelDesc].[Series].[' + @Series + '] , [DealerInformation].[Region Name].[' + @Region + '] , [DealerInformation].[Organisation ID].[' + @Dealer + '] )}, { [Measures].[Turn(Months)] , [Measures].[DLRMixPercent] }) ON ROWS FROM [cube] WHERE ([StockApplication].[PWD App ID].[' + @AppID + ']) '' ) DLRTurn ON CONVERT(VARCHAR,NationalTurn."[ModelDesc].[Series].[Series].[MEMBER_CAPTION]") = CONVERT(VARCHAR,DLRTurn."[ModelDesc].[Series].[Series].[MEMBER_CAPTION]") AND CONVERT(VARCHAR,RegionalTurn."[DealerInformation].[Region Name].[Region Name].[MEMBER_CAPTION]") = CONVERT(VARCHAR,DLRTurn."[DealerInformation].[Region Name].[Region Name].[MEMBER_CAPTION]") ) tblCube'
EXEC sp_executesql @SQL
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Friday, December 02, 2011 12:11 AM
Points: 125,
Visits: 77
|
|
Rick,
Maybe I get your question wrong, but wouldn't it help to do a left join to the last query, so it would return the results of the first two queries even if there are no results of the third query?
Hope this helps Martin
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Thursday, April 18, 2013 1:24 AM
Points: 178,
Visits: 261
|
|
Martin Cremer (11/19/2011) Rick,
Maybe I get your question wrong, but wouldn't it help to do a left join to the last query, so it would return the results of the first two queries even if there are no results of the third query?
Hope this helps Martin It would be great if a left join would work, but because the field doesn't exist (the [DealerInformation].[Organisation ID].[Organisation ID].[MEMBER_CAPTION]) it still errors.
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Friday, December 02, 2011 12:11 AM
Points: 125,
Visits: 77
|
|
Hi Rick,
sorry, I hadn't thought of that problem.
I have one idea which might work. You could build your 3rd mdx in such a way that it always returns at least one record (for example by including the all member of some dimension in your WHERE-clause). Of course your final SELECT should not return this record. But this could be achieved by defining the correct ON-clause in the join.
I hope this helps.
Take care Martin
|
|
|
|