2
votes

I have searched many hours attempting to find an end-to-end solution to this problem.

I want to create a report action in an SSAS OLAP cube that generates a list of formatted values to pass into an SSRS report parameter that accepts a multi-valued parameter list. This would be applied at the cell level in the SSAS action. I have found a solution that gets me most of the way: How to Pass Multiple Values from an SSAS Report Drill Through Action to an SSRS Multi-Value Parameter, but not quite. The action does appear in Excel and works if I run the action from a cell that is at or below the dimension attribute I am generating the list for, in this case, Account Key.

Below is a link to a screen capture (unable to embed it due to lack of reputation) showing the action and dimension structure in Excel. The action works as long as I run it at the Account Key level or below. I want to be able to run it at higher levels, such as Account Major and still have it generate all then related Account Key values for the SSRS report parameter. Running it at the higher Account Major level does not trigger the report to run.

Excel Action Screen Shot: http://i.stack.imgur.com/QCGSp.png

Below is the MDX I am using to generate the value for the report parameter:

UrlEscapeFragment(
    GENERATE(
        DESCENDANTS(
            [Account].[Account Key].CurrentMember, 
            [Account].[Account Key].[Account Key]
        ),
        [Account].[Account Key].CURRENTMEMBER.Name,
        "&rp:Account="
    )
)

I am hoping that I can somehow modify the MDX above to make it return all the Account Keys for any attribute of the Account dimension when ran from any measure cell, not just when ran at self and children of Account Key in the pivot table.

Also, if it helps, I can execute the following MDX query on the cube and get the results I am looking for.

WITH MEMBER [Measures].[Account Key List] as 
GENERATE(
    DESCENDANTS([Account].[Account].CurrentMember, [Account].[Account].[Account]),
    [Account].[Account].CURRENTMEMBER.NAME,
    "&rp:Account=")

SELECT {[Measures].[Account Key List]} on 0,
([Account].[Account Company Number].[Account Company Number],[Account].[Account Major].[Account Major]
)  on 1
FROM  [Company 10 Action Demo]

Below are partial results:

10.116&rp:Account=10.116.010
10.117&rp:Account=10.117.010&rp:Account=10.117.020
10.120&rp:Account=10.120.005&rp:Account=10.120.006&rp:Account=10.120.010&rp:Account=10.120.020&rp:Account=10.120.030&rp:Account=10.120.040&rp:Account=10.120.050&rp:Account=10.120.060&rp:Account=10.120.380&rp:Account=10.120.999
10.123
Questions
  • Any ideas what I might need to do to get Account Key to be returned for any attribute of the Account dimension?
  • Would I possibly have to alter my Account dimension in the cube to get this to work?

Thanks in advance.

Edit 1 - Adventure Works Cube Version

I was unable to get the suggested answer with the "Exists" function to work. To better demonstrate this issue, I have recreated it using the Adventure Works Cube.

I will focus on the Customer dimension, specifically the Customer and Education attributes. I created a report action called Test Report Action. Below is the XML created for it in the cube.

    <Action xsi:type="ReportAction" dwd:design-time-name="f35ad5ee-5167-4fb8-a0e0-0a74cc6e81c6">
      <ID>Report Action 1</ID>
      <Name>Test Report Action</Name>
      <TargetType>Cells</TargetType>
      <Target></Target>
      <Type>Report</Type>
      <ReportServer>SQLSERVER</ReportServer>
      <Path>ReportServer?/Test Report</Path>
      <ReportParameters>
        <ReportParameter>
          <Name>Test Customer Existing</Name>
          <Value>UrlEscapeFragment(
    GENERATE(
       EXISTING DESCENDANTS(
            [Customer].[Customer].CurrentMember, 
            [Customer].[Customer].[Customer]
        ),
        [Customer].[Customer].CURRENTMEMBER.Name,
        "&amp;rp:Customer="
    )
)</Value>
        </ReportParameter>
      </ReportParameters>
      <ReportFormatParameters>
        <ReportFormatParameter>
          <Name>rs:Command</Name>
          <Value>Render</Value>
        </ReportFormatParameter>
        <ReportFormatParameter>
          <Name>rs:Renderer</Name>
          <Value>HTML5</Value>
        </ReportFormatParameter>
      </ReportFormatParameters>
    </Action>

Below are the steps to re-create the issue.

  1. Connect to the cube in Excel
  2. Add dimension Customer -> More Fields -> Customer
  3. Add measure Internet Sales -> Internet Sales Amount
  4. Right-click Internet Sales Amount cell, select "Additional Actions" -> "Test Report Action" and see customer values created for URL

When the action is ran at this point with Customer, I see the values created in the URL shown message box (since there is no SSRS report server at location specified).

Now the part I'm unable to resolve

  1. Remove the Customer dimension and add Customer -> Demographic -> Education
  2. Right-click Internet Sales Amount cell, select "Additional Actions" -> "Test Report Action"

Nothing happens. If I ran the action on the cell next to "Bachelors", I would want it to build up all the list of all the "Customers" that make up the "Bachelors" in the Customer dimension as part of the report parameter. If no attributes where used in the cube from the Customer dimension for that cell, then I would like it to return "All Customers", or something similar to show that all customers are included in the aggregations.

I am not too MDX savvy, thus far. I think I need to somehow join the Customers to Internet Sales Amount in the Generate function portion. I have tried several different combinations of the Customer dimension and Internet Sales Amount, along with various functions to see if I could get this to work with no success. I am hoping that someone more knowledgeable the me will have a solution. If you need more details, please ask and I will provide them.

2
just wondering if you can translate this onto AdvWrks so people have something easier to play with?whytheq
I have considered installing the AdventureWorks DW and cube anyway since so many examples reference it. I'll find out if your suggested answer works tomorrow. If not, I'll rephrase the question using AdventureWorks. Thx.Shayne Ephraim

2 Answers

0
votes

Maybe the mdx needs to be made aware of the current cell context via the EXISTING keyword?

UrlEscapeFragment(
    GENERATE(
        EXISTING DESCENDANTS(
            [Account].[Account Key].CurrentMember, 
            [Account].[Account Key].[Account Key]
        ),
        [Account].[Account Key].CURRENTMEMBER.Name,
        "&rp:Account="
    )
)
0
votes

I finally found a solution to my problem. @wytheq was on the right track with MDX Exists and I would up-vote his answer if I could.

What I ended up doing was getting a list of values from a degenerate dimension that I could use to pass to SSRS to get a list of transactions for a report. Below is how I did this, in relation to the Adventure Works cube using the degenerate dimension Internet Order Details.

WITH MEMBER [Measures].[Order Param List] AS
    GENERATE(
        EXISTS([Internet Sales Order Details].[Sales Order Number].[Sales Order Number].Members, ,
            "Internet Sales"),
    [Internet Sales Order Details].[Sales Order Number].CurrentMember.Name,
    "&rp:OrderNum=")

SELECT {[Measures].[Order Param List], [Measures].[Internet Sales Amount]} ON 0
    ,([Date].[Calendar].[Date]) ON 1
FROM [Adventure Works]

This will get a list of Sales Order Number in a text string, separated by "&rp:OrderNum=" for each measure of Internet Sales. This would allow me to create an SSRS report to bring back detail information for each Sales Order Number. Below are some sample results.

May 16, 2007    SO50493&rp:OrderNum=SO50494&rp:OrderNum=SO50495&rp:OrderNum=SO50496&rp:OrderNum=SO50497&rp:OrderNum=SO50498&rp:OrderNum=SO50499&rp:OrderNum=SO50500 $12,157.80
May 17, 2007    SO50501&rp:OrderNum=SO50502&rp:OrderNum=SO50503&rp:OrderNum=SO50504&rp:OrderNum=SO50505&rp:OrderNum=SO50506&rp:OrderNum=SO50507&rp:OrderNum=SO50508 $13,231.62
May 18, 2007    SO50509&rp:OrderNum=SO50510 $4,624.91

With this, I can then create a Report Action in SSRS with a Parameter Value of

UrlEscapeFragment(
    GENERATE(
            EXISTS([Internet Sales Order Details].[Sales Order Number].[Sales Order Number].Members, ,
                "Internet Sales"),
        [Internet Sales Order Details].[Sales Order Number].CurrentMember.Name,
        "&rp:OrderNum=")
        )

The way I was going about it before was flawed, as I was trying to get a list of the granular values from each dimension used to build the measure value and pass each one of those as separate parameters. I just needed to set something unique for each fact measure transaction that represents the value and uses that in a query parameter for the SSRS report.