Search code examples
sql-serverreporting-servicesssrs-2008-r2ssrs-tablix

SSRS: Use parameter selection as a condition in Query


How to use parameter values as a condition in SSRS Query.. enter image description here

parameters:

date_from :datetime 
date_to :datetime
cust: text (label:Yes , Value :Y & Label :No , value:N)

Query:

SELECT dbo.incident.incident_ref,Customer.cust_n,incident.date_logged 
FROM incident
INNER JOIN Customer ON incident.incident_id = Customer.cust_id
WHERE incident.date_logged BETWEEN @date_from AND DATEADD(day, 1, @date_to)

I would to use a condition here to display customer based on my selection in dropdownlist (Include ABC)


Solution

  • You could try changing the query to:

    SELECT dbo.incident.incident_ref,Customer.cust_n,incident.date_logged 
    FROM incident
    INNER JOIN Customer ON incident.incident_id = Customer.cust_id
    WHERE 
        incident.date_logged BETWEEN @date_from AND DATEADD(day, 1, @date_to) and
        customer.cust_n = (case when @cust = 'N' and customer.cust_n = 'ABC' then NULL else customer.cust_n end)