Twp multi select parameters in SSRS not displaying results for when selected more than one value

前端 未结 1 887
我寻月下人不归
我寻月下人不归 2021-01-23 12:00

I have an issue with SSRS report not populating second multi value drop down list which is dependent upon first multi-valued drop down list and hence not populating report.

相关标签:
1条回答
  • 2021-01-23 12:32

    You have 2 options.

    Option 1. Make the SSRS dropdown a single value dropdown.

    If that is not a viable option, then here is option 2:

    You are going to have to make the data type for the @Office and @Servicetype parameters in the stored procedure something like an (n)varchar(1000); something long enough to handle a string with all possible values. Then you have to split the string into individual values so you can use them in the IN clause. Here is a split UDF I have used in the past (and posted on this site several times).

    CREATE FUNCTION [dbo].[udf_Split] 
       (  @List      varchar(8000), 
          @Delimiter varchar(5)
       ) 
       RETURNS @TableOfValues table 
          (  RowID   smallint IDENTITY(1,1), 
             [Value] varchar(100) 
          ) 
    AS 
       BEGIN
    
          DECLARE @LenString int 
    
          WHILE len( @List ) > 0 
             BEGIN 
    
                SELECT @LenString = 
                   (CASE charindex( @Delimiter, @List ) 
                       WHEN 0 THEN len( @List ) 
                       ELSE ( charindex( @Delimiter, @List ) -1 )
                    END
                   ) 
    
                INSERT INTO @TableOfValues 
                   SELECT substring( @List, 1, @LenString )
    
                SELECT @List = 
                   (CASE ( len( @List ) - @LenString ) 
                       WHEN 0 THEN '' 
                       ELSE right( @List, len( @List ) - @LenString - 1 ) 
                    END
                   ) 
             END
    
          RETURN 
    
       END 
    

    Once you have that in place (in your database), you can change your SP code to look like this in the WHERE clause.

    WHERE 
        fa.new_sitename IN (SELECT value FROM dbo.udf_Split(@Office, ','))
        AND fs.skillname IN (SELECT value FROM dbo.udf_Split(@Servicetype, ','))
    

    Enjoy!

    0 讨论(0)
提交回复
热议问题