在SSRS报告中使用案例条件使用基于日期的计算

时间:2018-07-05 06:03:56

标签: sql-server reporting-services ssrs-2008 ssrs-2008-r2

Select 
Case When @Date between '04/01/2018' and '05/31/2018' Then 0.06
     When @Date between '06/01/2018' and '06/30/2018' Then 0.07
     When @Date between '07/01/2018' and '07/31/2018' Then 0.08 
Else 0.06 End

2 个答案:

答案 0 :(得分:1)

这应该有效。

{% for source in incident.source.all %} 
    {{ source.url }}
{% if not forloop.last %},
{% endif %}{% endfor %}

更新:备用选项。使用=round(Sum(Fields!BASE_APR_1ST.Value, "score"))* IIF(Parameters!TODATE.Value >= "04/01/2018" and Parameters!TODATE.Value <= "05/31/2018" ,0.06 ,IIF(Parameters!TODATE.Value >= "06/01/2018" and Parameters!TODATE.Value <= "06/30/2018" ,0.07 ,IIF(Parameters!TODATE.Value >= "07/01/2018" and Parameters!TODATE.Value <= "07/31/2018" ,0.08,0.06)))

Switch

答案 1 :(得分:0)

我认为您可以使用自定义代码来实现此要求。
右键单击报表的空白区域->“报表属性”->代码

Function GetDate(ByVal dt As DateTime) As String
    If (dt >= Date.Parse("04/01/2018") AndAlso dt <= Date.Parse("05/31/2018")) Then
        Return "0.06"
    ElseIf (dt >= Date.Parse("06/01/2018") AndAlso dt <= Date.Parse("06/30/2018")) Then
        Return "0.07"
    ElseIf (dt >= Date.Parse("07/01/2018") AndAlso dt <= Date.Parse("07/31/2018")) Then
        Return "0.08"
    Else
        Return "-"
    End If
End Function

然后在文本框的表达式中调用此函数,如下所示:“ = Code.GetDate(Fields!Date.Value)”