0
votes

Please help me to use (date, Boolen and integer) parameters in SSRS 2008.

How to call boolen value in SQL query for condition

Attached screen for reference.

enter image description here

Reports:

  1. Need to display result while select from and To Date
  2. Need to display while select only "Last N Days"
  3. Include ABC -It display only the result based on ABC customers

My Query for date filter :

WHERE    dbo.incident.date_logged BETWEEN @date_from AND DATEADD(day, 1, @date_to)    OR dbo.incident.date_logged >= DATEADD(day, -@InDays, GETDATE())
AND    item.item_n in (@sn)
1
Are you actually after 3 separate reports? Or can all three conditions exist on the same rport? And can some of the conditions be combined (as I think it is unlikely 1 and 2 can be used together)? - Jonnus
@Jonnus : No its single report. If I select "include ABC" is "Yes" then is will display all info from customer including ABC. If "No" display other customers without ABC - Sam Bin Ham

1 Answers

0
votes

Maybe avoid that prompt setup... is not very intuitive.

Have only one report with "Date From" and "Date to" and the "Include ABC" that works better with a Dropdown.(Just like you have done that in another question)

You can setup another report that runs your original report but has another prompt setup just with "LastnDays" and "include ABC". And runs the original one with the dates you want and the "boolean".

EDIT:

Still don't think that's the best way to go.

Try something like this:

WHERE 
    incident.date_logged BETWEEN 
        CASE WHEN @N_last_days is null THEN @date_from else DATEADD(day, @N_last_days*-1, getdate()) AND 
        CASE WHEN @N_last_days is null THEN DATEADD(day, 1, @date_to) ELSE getdate() END
    AND
    customer.cust_n = (case when @cust = 'N' and customer.cust_n = 'ABC' then NULL else customer.cust_n end)