Forum Discussion
Redshift Native SQL is not supporting to pass the multiselect parameters in report builder
Hi,
I was trying to write custom SQL with ODBC connector for redshift view.
In fx option in report builder, when I write my redshift SQL like, select * from sales where region IN @regionparameter
and sales_date >=@startdateparameter and sales_date <=@enddateparameter, it is throughing error message saying syntax is not proper.
Could anyone please let me share with redshift view how can we write exact SQL code to pass the multiple values in slicer with date range date picker in Report Builder.
Thanks,
Srinivas.
Hi Koritala ,
As per this document not all data sources support parametersSource: Report parameters in Power BI Report Builder - Power BI | Microsoft Learn
If you still feel the issue is important and not related to source. Please consider reaching out to Microsoft Support. You can provide them with all the troubleshooting steps you've already taken, which will help them understand the issue better and provide a resolution. They might be able to identify something specific about your admin account setup or provide a solution that isn't immediately obvious.
Below is the link to create Microsoft Support ticket:
How to create a Fabric and Power BI Support ticket - Power BI | Microsoft Learn
Thank you
16 Replies
- DataNinja777Super User
Koritala ,
Redshift does not support directly using multiselect parameters in the form IN (@param) when used in Report Builder with the ODBC connector. The issue is that Report Builder passes multivalue parameters as a single comma-separated string, but Redshift expects a proper list for the IN clause. This mismatch leads to syntax errors. To work around this, you can split the comma-separated string into individual values using regexp_split_to_table, and then join that result to your main query.
Here is how the SQL should be written in your Report Builder custom SQL query:
WITH region_split AS ( SELECT TRIM(value) AS region FROM regexp_split_to_table(:regionparameter, ',') AS value ) SELECT * FROM sales s JOIN region_split r ON s.region = r.region WHERE s.sales_date >= :startdateparameter AND s.sales_date <= :enddateparameterMake sure in Report Builder that @regionparameter is configured as a multivalue parameter, and it will be passed as a string like 'East,West,North'. The regexp_split_to_table function breaks this string into rows, which can then be joined with your sales table. Also, be sure to replace @ with : for parameter names when using ODBC with Redshift, as the @ symbol is not always recognized correctly in native SQL execution. This approach allows you to dynamically filter based on multiple selected regions and a date range.
Best regards,
- ajaybabuinturiSuper User
Hi Koritala,
I am assuming regionparameter as a text parameter that is a comma-separated string of values ('East','West','North'). regionparameter is a multi-value parameter, and SQL doesn't directly accept it in the IN clause via @parameter syntax.
Can you try with below updated SQL code. Let me know if you have any questions.
select * from sales where region in ( select trim(value) from regexp_split_to_table(@regionparameter, ',') as value ) and sales_date >= @startdateparameter and sales_date <= @enddateparameterThanks,
If you found this solution helpful, please consider giving it a Like👍 and marking it as Accepted Solution✔. This helps improve visibility for others who may be encountering/facing same questions/issues.- KoritalaPost Patron
Hi Ajay,
Thanks for your response.
I have a question in your provided code What does it mean by "trim(value)". Do you want me to give as similar your code?
Thanks,
Koritala
- ajaybabuinturiSuper User
Hi Koritala,
The value is the default column name returned by Redshift’s STRING_TO_TABLE function. STRING_TO_TABLE(@regionparameter, ',') turns a comma-separated string (like 'East,West,North') into a table, where each row contains one region. That temporary table has one column, and it's automatically named value.
- KoritalaPost Patron
Hi Ajay,
Can you please share the SQL code where I need to pass the product and caegory parameters along with region parameter.
Thanks,
Srinivas.
- ajaybabuinturiSuper User
Hi Koritala,
Try with below code
select * from sales where region in (select trim(value) from regexp_split_to_table(@regionparameter, ',') as value) and product in (select trim(value) from regexp_split_to_table(@productparameter, ',') as value) and caegory in (select trim(value) from regexp_split_to_table(@categoryparameter, ',') as value) and sales_date >= @startdateparameter and sales_date <= @enddateparameterThanks,
If you found this solution helpful, please consider giving it a Like👍 and marking it as Accepted Solution✔. This helps improve visibility for others who may be encountering/facing same questions/issues.