简体   繁体   English

选择多个值时,SSRS 中的 Twp 多选参数不显示结果

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

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.我有一个问题,SSRS 报告不填充第二个多值下拉列表,该列表依赖于第一个多值下拉列表,因此不填充报告。

So, what I am trying to do here is populating SSRS report for construction contractors from selected cities from first drop down list and selected skills sets from second drop down list which gets populated once we select Cities drop down list.因此,我在这里尝试做的是从第一个下拉列表中为选定城市的建筑承包商填充 SSRS 报告,并从第二个下拉列表中填充选定的技能集,一旦我们选择了城市下拉列表,就会填充该报告。

But my issue is when I select one city the skill's drop-down list get populated without any problem, when I select more than one city , my skill's drop down show no value.但我的问题是当我选择一个城市时,技能的下拉列表会毫无问题地填充,当我选择多个城市时,我的技能下拉列表没有任何价值。

My code is as follows.我的代码如下。 I have 3 datasets.我有 3 个数据集。

Dataset 1 (Main)数据集 1(主要)

ALTER PROCEDURE [dbo].[RPT_ADM_Total_Contractors]

    @Office nvarchar(255),
    @Start datetime,
    @End datetime,
    @Servicetype nvarchar(255)

AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    SELECT    fs.skillname,fa.NEW_ContractorIDNAME AS ContractorName, fa.new_Contractorstatusname AS Contractorstatus,
          fa.createdon AS CreatedDate, fa.new_addresscity AS City
    FROM 
        Filterednew_contrator fa
    join
        FilteredService fs
    on fa.new_service = fs.serviceid

    WHERE 
    fa.new_sitename IN (@Office )
    AND fs.skillname IN (@Servicetype)


END

Dataset 2数据集 2

ALTER PROCEDURE [dbo].[RPT_ADM_Total_Contractors_Officelist]
    @Start date,
    @End date
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

        SELECT DISTINCT fa.new_sitename
    FROM 
        Filterednew_contrator fa
    join
        FilteredService fs
    on fa.new_service = fs.serviceid    
    WHERE       
        new_admitdate between @Start and @End
        AND new_sitename like 'Office%'
        fa.new_service is not null

END

Dataset 3数据集 3

ALTER PROCEDURE [dbo].[RPT_ADM_Total_Contractors_Servicetypelist]

        @Office nvarchar(255)
        --@Start datetime,
        --@End datetime

AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    SELECT DISTINCT fs.skillname
    FROM 
        Filterednew_contrator fa
    join
        FilteredService fs
    on fa.new_service = fs.serviceid
    WHERE
    fa.new_sitename in (@Office)        
    order by fs.skillname


END

I have 4 paramters我有 4 个参数

@Start date/time
@End date/time
@Office "Allow Multivalue" AND gets populated from dataset 2
@Servicetype "Allow Mutivalue" AND gets populated from dataset 3

I tried using =Join(Parameters!Office.Value,",") but didn't work.我尝试使用 =Join(Parameters!Office.Value,",") 但没有用。 I hope someone ca help me out with this.我希望有人能帮我解决这个问题。

Thanks.谢谢。

You have 2 options.您有 2 个选择。

Option 1. Make the SSRS dropdown a single value dropdown.选项 1. 将 SSRS 下拉列表设为单值下拉列表。

If that is not a viable option, then here is option 2:如果这不是一个可行的选择,那么这里是选项 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);您将不得不为存储过程中的@Office 和@Servicetype 参数创建类似于 (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.然后您必须将字符串拆分为单独的值,以便您可以在 IN 子句中使用它们。 Here is a split UDF I have used in the past (and posted on this site several times).这是我过去使用过的拆分 UDF(并在此站点上多次发布)。

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 子句中将你的 SP 代码更改为如下所示。

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

Enjoy!享受!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 "在 select 的子句中,但要查找多个值" - In clause of a select but with more than one value to look for 在选择了多个列的SELECT中使用Distinct(col) - Using Distinct(col) in a SELECT with more than one column selected 具有覆盖索引的SSRS 2005多值参数 - SSRS 2005 Multi Value Parameters with Covering Index 选择返回比主选择多一的值 - Select return more value than one to main select 根据具有多个值的参数过滤SQL查询 - Filtering SQL query based on parameters with more than one value SSRS 中的两个多值参数 - Two multi-value parameters in SSRS 如果id只有一条记录,则选择一条有空值的记录,当id有多条记录时,选择非空值 - Select a record having null if the id has only one record and select not null value when the id has more than one record 没有为一个或多个必需参数给出值 当所有参数都给出时 - No value given for one or more required parameters When all parameters are given 嵌套SELECT抛出异常“没有给出一个或多个必需参数的值” - Nested SELECT throws an exception “No value given for one or more required parameters” select 查询中的一个或多个必需参数未给出值 - No value given for one or more required parameters in select query
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM