【问题标题】:SSRS IIF parameter equal to NULL run report as normalSSRS IIF 参数等于 NULL 正常运行报告
【发布时间】:2014-11-03 00:08:58
【问题描述】:

我正在 SSRS 中编写一份报告,它需要一个搜索参数来过滤报告。该参数设置为默认允许空值,这应该让报告正常运行。

报告运行,但是在我将某些内容添加到搜索参数中之前,什么都没有返回。

是否可以使用 IIF 表达式表示如果参数为空,则正常运行报告?

这是我用来在 SSRS 中生成数据集的查询。

CREATE TABLE #StartDateTable(

  stSecurityType varchar(10) NOT NULL,
  stSecuritySymbol varchar(50) NOT NULL,
  stPrice float NOT NULL,
  stSecurityID int NOT NULL,
  stPriceDate date NOT NULL
)

INSERT INTO #StartDateTable (stSecurityType, stSecuritySymbol, stPrice, stSecurityID, stPriceDate )
    SELECT DISTINCT 
       Instruments.SecurityType, Instruments.SecuritySymbol, 
       InstrumentPrice.Price, InstrumentPrice.SecurityID, InstrumentPrice.PriceDate
    FROM 
       InstrumentPrice
    JOIN 
       Instruments ON Instruments.ID = InstrumentPrice.SecurityID
    WHERE 
       InstrumentPrice.PriceDate = @StartDate;

CREATE TABLE #EndDateTable
(
      etSecurityType varchar(10) NOT NULL,
      etSecuritySymbol varchar(50) NOT NULL,
      etPrice float NOT NULL,
      etSecurityID int NOT NULL,
      etPriceDate date NOT NULL
)

INSERT INTO #EndDateTable (etSecurityType, etSecuritySymbol, etPrice, etSecurityID, etPriceDate)
   SELECT DISTINCT 
      Instruments.SecurityType, Instruments.SecuritySymbol, 
      InstrumentPrice.Price, InstrumentPrice.SecurityID, 
      InstrumentPrice.PriceDate
   FROM 
      InstrumentPrice
   JOIN 
      Instruments ON Instruments.ID = InstrumentPrice.SecurityID
   WHERE 
      InstrumentPrice.PriceDate = @EndDate;

SELECT * 
FROM #StartDateTable
LEFT JOIN #EndDateTable ON #EndDateTable.etSecurityID = #StartDateTable.stSecurityID   

我使用 LIKE 将搜索参数设置为 SSRS 中数据集的过滤器,因为我希望它是通配符。

【问题讨论】:

    标签: reporting-services ssrs-2008-r2


    【解决方案1】:

    有两种方法可以做到这一点。使用 where 子句或下面的子句在 Dataset 进行过滤都使用组过滤器。

    从组属性中使用 between 和使用表达式..

    例如=IIF(Isnothing(Parameters!Param1.Value) = true, 0, Parameters!Param1.Value)=IIF(Isnothing(Parameters!Param1.Value) = true, 999999, Parameters!Param1.Value)

    【讨论】:

    • 嗨,t_m。感谢您的回复。我都试过了,或者你发布的 IIF 表达式都没有工作
    • 你能发布示例表结构和示例数据吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多