How to pass a dataset as a parameter in a report query?

I am trying to pass a dataset as a parameter to a SQL Query Data Source in a report.
The dataset has a list of IDs in the 'ID' column.
The query would be:

SELECT * FROM My_Table
WHERE id IN (?)

I tried setting Parameter 1 to groupConcat(my_dataset, 'ID', ',') but I think the parameter ends up like this "000, 001, 002, 003" instead of "000", "001", "002", "003"

Is this possible in the query data source, or do I have to do this in a script data source?

You can derive reports from a script so most things are possible. For example, you could look up a dataset within a script and output the report data from that.

I think this is the direction you need to go.

I'd like to do it in a query because I can give them names in the Data Sources sidebar, my scripts all are named "Script" and its hard to find the right one when I need to change things

Don't use more than one script in a report. Just do everything in a single script. For ease of maintenance, consider having that one script call a project library function to actually do the work.

(A single report data script can add as many data keys as you like.)

1 Like

I have 2 scripts, just to make sure data keys that are defined in 1 or 2 lines don't get buried by ones that need a lot more code.

What is the benefit of moving code to the project library? Wouldn't that make it more difficult to swap between the code, designer, and preview?

No, because you can float your project library script windows to keep them visible and editable.

2 Likes

TIL you can float a script by opening it in the designer, and right clicking the tab down at the bottom.

1 Like

Same, I had no idea this was a thing