1

我客户的财政年度从 11 月开始。我使用以下表达式对会计月份类别进行排序:

=Month(
    DateAdd(
        DateInterval.Month,
        -10,
        CDate(
            Fields!FiscalMonth.Value + ", 01 1900"
        )
    )
)

在我不得不将上一年的年终值添加到该类别之前,它运行良好。我认为使用这样的表达式进行排序是微不足道的:

=Iif(
    Fields!FiscalMonth.Value = "YearEnd",
    0,
    Month(
        DateAdd(
            DateInterval.Month,
            -10,
            CDate(
                Fields!FiscalMonth.Value + ", 01 1900"
            )
        )
    )
)

Conversion from string "YearEnd, 01 1900" to type 'Date' is not valid但它在值上抛出错误YearEnd。这应该是不可能的,因为Iif应该保护它的第二个参数。我还能如何确保为“YearEnd”分配了 0 排序顺序?

更新:

即使使用以下表达式也会发生错误:

=Iif(
    Fields!FiscalMonth.Value = "YearEnd",
    0,
    CDate(
        Fields!FiscalMonth.Value + ", 01 1900"
    )
)

但不会发生

=Iif(
    Fields!FiscalMonth.Value = "YearEnd",
    0,
    Fields!FiscalMonth.Value + ", 01 1900"
)

对我来说,这听起来像是 SSRS在评估第一个参数CDate()之前进行评估。Iif()一个错误。

4

1 回答 1

0

这有效:

=Iif(
    Fields!FiscalMonth.Value = "YearEnd",
    0,
    Month(
        DateAdd(
            DateInterval.Month,
            -10,
            CDate(
                Iif(Fields!FiscalMonth.Value = "YearEnd", "November", Fields!fiscalmonth.Value) + ", 01 1900"
            )
        )
    )
)

有谁知道我怎么能对微软大喊:如果第一个参数评估为“假”,则不要评估 Iif 的第二个参数,如果第一个参数评估为“真”,请不要评估 3D 参数???

于 2013-11-06T20:44:38.320 回答