Cascade parameters

  • I need some help with cascading parameters in a report with 2 stored procedures. My main sp (startdate and enddate parameters) has all the data I need except the sum of points (2nd sp) between startdate and enddate. The second sp has cstid, startdate and enddate as the parameters. The 2nd sp has all the points listed by cstkey,cstid, pointdatetaken, pointamt and pointtype. I'm not sure what is the best way to add in the 2nd sp so I can get all data I need from 1st sp and sum of points from 2nd sp by each customer. I appreciate any suggestions. Thank you.

  • mhaswood (10/28/2013)


    I need some help with cascading parameters in a report with 2 stored procedures. My main sp (startdate and enddate parameters) has all the data I need except the sum of points (2nd sp) between startdate and enddate. The second sp has cstid, startdate and enddate as the parameters. The 2nd sp has all the points listed by cstkey,cstid, pointdatetaken, pointamt and pointtype. I'm not sure what is the best way to add in the 2nd sp so I can get all data I need from 1st sp and sum of points from 2nd sp by each customer. I appreciate any suggestions. Thank you.

    You have stated that the 2nd SP will be used to populate a parameter. Are you sure that these are not just two datasets? What do you want displayed for each of the parameters?

    I think you are looking at two datasets, one for each SP.

    Option 1:

    If this is the case setup the report with a subreport. The main (header) report uses the Start and End parameters to populate the call to SP1. The subreport would be included within a tablix on the main report aligned to each row in the first SP. The subreport dataset would be based on SP2 with the Start and End date parameters passed (from the main report parameters) and the cstkey from the first dataset (on the main report). This would populate the SP2 data for each cstkey found using SP1.

    Option 2:

    You could change the dataset to use temporary tables (or CTE) to retrieve the results from the two SP and join the results into a single result set.

    Hope this helps, I my assumptions are wrong I will endeavour to answer with more details.

    Fitz

  • OPTION 3:

    Do it all in T-SQL (control SP that calls the other 2?) and just present the final result set to Reporting Services.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff Moden (10/29/2013)


    OPTION 3:

    Do it all in T-SQL (control SP that calls the other 2?) and just present the final result set to Reporting Services.

    Agreed, Jeff. If the assumptions are correct and the user can have a controlling SP then option 2 can be done on the server side only allowing for greater control.

    Fitz

  • I tried all your suggestions and option 3 worked. I was able to add in the points to the first sp and grouped all fields by cstkey in ssrs and got to display all the fields the way I wanted. Thank you so much for your help!

    mh:-)

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply