I am trying to get a basic SSRS report to be filterable by any optional parameters. The 2 parameters to filter should be either between 2 dates or by a SalesID. I can get each parameter to filter individually but when I add them together in a statement and try to run the report it says "parameter cannot be blank".The advices I read online says me to check the "allow blank values" in the parameter properties but this is not available for Date/Time.
I read them online and it asks me to check the "allow blank values" in the parameter properties but this is not available for Date/Time. I've also tried adding numerous variations of the WHERE clause using "OR IS NULL" but that doesn't work either.I also read that I might need to add an =IIF clause somewhere but I have never done this before.
Select SalesID, SalesDate, SaleValue
FROM SalesDb
WHERE (SalesDate BETWEEN @StartDate AND @EndDate AND SalesID IS NULL) OR
(SalesID = @SalesID AND @StartDate IS NULL and @EndDate IS NULL)
The above code runs if I select a Start Date and End Date but it only pulls through the SalesDate data and the other fields are blank.
I want the report to be filterable by either a Start and End Date or SalesID, not both. At present the above returns an error that-StartDate cannot be blank. As I mentioned above, I cannot check the "allow blank values". Thanks in advance.