Forum Discussion

razaross's avatar
razaross
Frequent Visitor
3 years ago
Solved

Paginated SubReport passing multivalue parameter from parent dataset

I have a paginated report that also contains a subreport. The parent report displays data from dataset dsMain. The subreport accepts a multivalue parameter. The subreport is not in the parent report'...
  • razaross's avatar
    razaross
    3 years ago

    Yes, I understand what subreports are and I don't want to make it part of parent data region. It's more of a summary of definitions of each category that gets displayed in the parent report and I don't want to run the same query more than once since it's a fairly expensive one.

     

    I actually got this to work by asking ChatGPT the exact question above how to do it and this is what it came up with:

     

    --------------------------------------------------------------------------

     

    1. In the parent report, create a query parameter that will hold the list of distinct CategoryIds. To do this, go to the "Report Data" pane, right-click on "Parameters", and select "Add Parameter". Give the parameter a name, such as "CategoryIds", and set the "Data type" to "Integer" and "Allow multiple values". In the "Available Values" section, choose "Get values from a query" and then select the dataset that will be used to populate the parameter with values.

    2. In the "Dataset" dropdown, select the dataset that contains the distinct CategoryIds (in this case, dsMain). In the "Value field" dropdown, select the field that contains the CategoryIds (in this case, "CategoryId").

    3. In the subreport, create a parameter that will receive the values from the parent report. To do this, go to the "Report Data" pane, right-click on "Parameters", and select "Add Parameter". Give the parameter the same name as the parameter in the parent report (in this case, "CategoryIds"), and set the "Data type" to "Integer" and "Allow multiple values". In the "Default values" section, choose "Get values from a query" and then select the dataset that will be used to populate the parameter with values.

    4. In the subreport, use the "CategoryIds" parameter in your query to filter the data that is displayed in the report. For example, you could use a WHERE clause like this:

    WHERE CategoryId IN (@CategoryIds)

     

    1. In the parent report, add the subreport to the report body, and then set the "CategoryIds" parameter of the subreport to the "CategoryIds" parameter of the parent report. To do this, right-click on the subreport and select "Subreport Properties". In the "Parameters" tab, you will see a list of parameters for the subreport. Click on the "CategoryIds" parameter and then click on the "fx" button. In the expression builder, click on the "Parameters" node and then select the "CategoryIds" parameter of the parent report.

    That's it! When you run the parent report, the subreport will be filtered using the list of CategoryIds that are gathered from the dsMain dataset of the parent report.

     

    -----------------------------------------------------------------------------------------

    ChatGPT for the WIN!! 🤣