donderdag 19 mei 2016

Report Builder: Trouble With Multivalue Parameters With Too Many Values

The other day I ran in to a problem with Report Builder. I had a number of multi value parameters with a lot of values. And there was a single value parameter for selecting items too. The report rendered fine in design mode. But as soon as I published it, it was no longer rendering properly.

The mutli value parameters also contained values which would not give any result at all given a certain item number. But then again, in design node no problem.

The solution I finally came up with was to interrelate the multi value parameters to the single value parameter by using a SQL  subquery.


Let's look at this example I created based on the NorthWind database. My main dataset:

SELECT        Customers.CustomerID, Customers.CompanyName, [Order Details].OrderID, [Order Details].ProductID, [Order Details].UnitPrice, [Order Details].Quantity, [Order Details].Discount, 
                         Orders.OrderDate, Products.ProductName
FROM            Orders INNER JOIN
                         [Order Details] ON Orders.OrderID = [Order Details].OrderID INNER JOIN
                         Customers ON Orders.CustomerID = Customers.CustomerID INNER JOIN
                         Products ON [Order Details].ProductID = Products.ProductID

Two more datastes for the multi value parameters:

Parameter: parProduct
select ProductID, ProductName from Products
where ProductID in
(
select ProductID  from vwOrdersCustomers
where OrderId = @parOrder)

Parameter:  parCustomer
select CustomerID, CompanyName from Customers
where CustomerID in
(
select CustomerID from vwOrdersCustomers
where OrderId = @parOrder)

And a single value parameter: parOrder.
Een reactie posten