0

I am trying to use cascading parameters to filter this Pivot table in SSRS Report Builder.

This is the main dataset query:

SELECT * FROM(
SELECT *,
    CASE WHEN PLN=PLN THEN '01. GROSS PREMIUM'
        ELSE NULL
    END AS PREMIUM
FROM MYI
PIVOT (SUM(GROSS_PREMIUM_1) FOR PERIOD_TYPE IN([MTD],[YTD],[ITD])) pvt

UNION ALL

SELECT *,
    CASE WHEN PLN=PLN THEN '02. REFUND'
        ELSE NULL
    END AS PREMIUM
FROM MYI
PIVOT (SUM(REFUND_2) FOR PERIOD_TYPE IN([MTD],[YTD],[ITD])) pvt
)A

WHERE ACC_PERIOD = @ACC_PERIOD
    AND REINSURER IN (@REINSURER)
    AND INSURER IN (@INSURER) 
    AND PLN IN (@PLN) 
    AND SVC_AGY IN (@SVC_AGY)

These parameters in the WHERE clause each have their own dataset and are cascaded from top to bottom. Here is the query for the final parameter as an example:

SELECT DISTINCT [fasren_servicingagency]
FROM [FAS_ReinsuranceNumber]
WHERE ACC_PERIOD = @ACC_PERIOD
    AND REINSURER IN (@REINSURER)
    AND INSURER IN (@INSURER)
    AND PLN IN (@PLN)
ORDER BY SVC_AGY

The query runs fine in SSMS, but I keep getting this error when I run it in the SSRS report builder:

An expression of non-boolean type specified in a context where a condition is expected, near ','

It must have something to do with the WHERE clause in either the main query or the parameter dataset queries. I have seen many posts about this error but I could not find a solution that helped with my problem. Any ideas?

NOTE: all parameters are character fields, no integers, no date columns.

EDIT: There is another query that I was successful with;

SELECT [acctyymm],
    [retrosummary],
    [retroagent],
    [coveragedivision],
    [policyinsurer],
    SUM([NetDue]) AS NET_DUE,
    SUM([ActualPayable]) AS PAYABLE
FROM [dbo].[RetroNumberGAAP]
WHERE [acctyymm] IN (@ACC_PERIOD)
    AND [retrosummary] IN (@RETSUM)
    AND [retroagent] IN (@RETAGT)
    AND [coveragedivision] IN (@PLN)
    AND [policyinsurer] IN (@INSURER)
    AND POWER([fasrtng_NetDue],2)+POWER([ActualPayable],2)<>0
GROUP BY [acctyymm],
    [retrosummary],
    [retroagent],
    [coveragedivision],
    [policyinsurer]

How am I successful running the report with cascaded parameters in this second query and not the first query?

Clifford Piehl
  • 483
  • 1
  • 4
  • 11
  • I'm guessing that you're trying to pass comma separated lists as the parameters for the `IN (...)` parts of the `WHERE` clause. This won't work. See my comments under https://stackoverflow.com/questions/58774178/how-to-pass-lists-as-variables-into-where-in-clause-sql-server – Skippy Nov 08 '19 at 22:25
  • Are you sure that you're `@ACC_Period` isn't Multi-Value? You can just change it to `WHERE ACC_PERIOD IN (@ACC_PERIOD)` to check it. – Hannover Fist Nov 09 '19 at 00:26
  • @Skippy suggests the error might result from having commas in `@REINSURER`, `@INSURER` or `@PLN`. That won't cause an error. `... where ... in ( 'Red,Blue,White' )` will evaluate to `true` if the expression is equal to the _one_ target value (commas and all): `'Red,Blue,White'`. That may not be what you want, but it is valid. Aside: That's an interesting use of `case` expressions to check for `null`: `CASE WHEN PLN=PLN THEN '01. GROSS PREMIUM' ELSE NULL END AS PREMIUM`. – HABO Nov 09 '19 at 04:13
  • @HABO - ah yes completely correct, oops! I also didn't spot that this was SSRS, which puts a different slant on things. – Skippy Nov 09 '19 at 05:13
  • @Skippy I am still not sure what I am supposed to do. This method worked fine in another query from a different report (I have edited the post to show what that looks like). What is the difference between these queries? I have also tried Hannover-Fist's suggestion. – Clifford Piehl Nov 11 '19 at 15:31
  • Sorry I didn't get back to you sooner, but my response wouldn't have been much help - I would just have said that if it's a Reporting Services problem then I would need to be sitting in front of the machine to work through it because there are so many places you can trip up! Glad you figured it out, well done. – Skippy Nov 13 '19 at 10:13

1 Answers1

0

I figured out what I did wrong. My Dataset properties were not configured correctly in the Report Builder.

WRONG CONFIGURATION

Dataset properties; Parameters; parameter name: SVC_AGY Parameter Value: [@SVC_AGY]

CORRECTED CONFIGURATION

Dataset properties; Parameters; parameter name: @SVC_AGY Parameter Value: [@SVC_AGY]

Make sure your parameter names match your parameter values, including the @ symbol.

Clifford Piehl
  • 483
  • 1
  • 4
  • 11