代码之家  ›  专栏  ›  技术社区  ›  Rachel

派生列表达式不工作,但未给出错误

  •  0
  • Rachel  · 技术社区  · 8 年前

    我正在尝试编写一个公式,根据报告期(varchar)为我提供基本交易金额(Int)

    因此,如果报告期为201803,则表达式应计算该期是否大于去年同月201701或小于去年下月201702,或是否介于今年的01和02之间,依此类推。

    我得出了以下公式,但没有给我一个错误,但当我运行包时,我在派生列中得到了0,而它应该是基本交易金额。

    PrevYear01列:(ReportingPeriod>=“Year(getdate()-1)”+“01”)&&(报告期<“年(getdate()-1)”+“02”)?BaseTransactionAmount:0

    ThisYear01列:(ReportingPeriod>=“Year(getdate())”+“01”)&&(ReportingPeriod<“Year(getdate())”+“02”)?BaseTransactionAmount:0

    请帮忙!

    1 回复  |  直到 8 年前
        1
  •  2
  •   Jayvee    8 年前

    在连接之前,可能需要强制转换计算年份:

    (DT_WSTR,4)(year(getdate())-1) +"01"
    
    推荐文章