Multiple Dropdown in Visual Studio 2008 not filtering correctly -
i using visual basic 2008 ssrs , backend sql server 2008 create reports. trying create 2 parameterized dropdowns user can select in order filter data in reports. reason can't seem both parameters filter 1 filters correctly. when run report in visual studio 2008 choose dropdown1 equal 2 , dropdown2 equal 4. should show 1 row, reason second filter seems work. need modify sql maybe?? appreciated, thank you.
**table 1** **table 2** **table 3** key1 key2 data1 key3 data2 data3 1 1 hi 2 green white 4 1 2 green white 2 hey 3 red black 3 hi 1 orange purple 1 hey 4 blue black 4 hey 4 blue purple **current result** **desired** data1 data2 data3 data1 data2 data3 hi orange purple hi orange purple hey blue purple **parameters-** @dropdown1- available values label value hihey 1 hi 2 **@dropdown2- avilable values** label value greenblue 3 purple 4 query designer- select l.key1, c.data, aa.data2, aa.data3 table1 l inner join table2 c on l.key1 = c.key2 inner join table3 aa on l.key1 = aa.key3 ((@dropdown1= 1 , c.data1 ='hi' or c.data1 ='hey' ) or (@dropdown1= 2 , c.data1 ='hi')) , (( (@dropdown2= 3 , aa.data2 in ('green', 'blue')) or (@dropdown2= 4 , aa.data3 ='purple') ))
not quite sure logic, desired result, or clause in condition needs bracketed.
((@dropdown1= 1 , (c.data1 ='hi' or c.data1 ='hey') )
a demonstration of full codes:
declare @table1 table (key1 int) declare @table2 table (key2 int, data1 varchar(10)) declare @table3 table (key3 int, data2 varchar(10), data3 varchar(10)) insert @table1 select 1 union select 4 insert @table2 values (1, 'hi'), (1, 'you'), (2, 'hey'), (3, 'hi'), (1, 'hey'), (4, 'hey') insert @table3 values (2, 'green', 'white'), (2, 'green', 'white'), (3, 'red', 'black'), (1, 'orange', 'purple'), (4, 'blue', 'black'), (4, 'blue', 'purple') select * @table1 select * @table2 select * @table3 declare @dropdown1 int = 2, @dropdown2 int = 4 select l.key1, c.data1,aa.data2,aa.data3 @table1 l join @table2 c on l.key1 = c.key2 inner join @table3 aa on l.key1 = aa.key3 ( (@dropdown1= 1 , (c.data1 ='hi' or c.data1 ='hey') ) or (@dropdown1= 2 , c.data1 ='hi')) , (( (@dropdown2= 3 , aa.data2 in ('green', 'blue')) or (@dropdown2= 4 , aa.data3 ='purple') ))
Comments
Post a Comment