Sam Bin Ham
Sam Bin Ham

Reputation: 449

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)

Upvotes: 1

Views: 454

Answers (1)

mxix
mxix

Reputation: 3659

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)

Upvotes: 1

Related Questions