SSRS中月份= 1时获得月份-1时出错

时间:2016-02-10 15:42:29

标签: reporting-services

我有一个文本框,显示用户选择的月份的月份名称,但它总是减1.我选择1月时出错,因为它应该显示12月。所以我做的是:

*ODS DOCUMENT creates the DOCUMENT object you will later modify;
ods document name=freqs(write);
** SINGLE PASS ON PROC FREQ **;
PROC FREQ DATA = TEST;
    TITLE "TEMPERATURE FREQS";
      TABLE TEMPERATURE / LIST OUT=FREQS_TEMP;
    TITLE "HUMIDITY FREQS";
      TABLE HUMIDITY / LIST OUT=FREQS_HUM;
    TITLE "PLATE FREQS";
      TABLE PLATE / LIST OUT=FREQS_PLATE;
    TITLE "FORM FREQS";
      TABLE FORM / LIST OUT=FREQS_FORM;
RUN;
title;
ods document close;


*PROC DOCUMENT is an interactive proc, so it stays active until QUIT;
proc document name=freqs;
  *Just a look at what it looks like under the hood - can be removed in production;
  list/levels=all;
run;

  *Here we create page breaks (OBPAGE command) after each table.;
  obpage \Freq#1\Table1#1\OneWayFreqs#1 /after;
  obpage \Freq#1\Table2#1\OneWayFreqs#1 /after;
  obpage \Freq#1\Table3#1\OneWayFreqs#1 /after;


  *Here we add the titles.;
  obtitle \Freq#1\Table1#1\OneWayFreqs#1 "TEMPERATURE FREQS";
  obtitle \Freq#1\Table2#1\OneWayFreqs#1 "HUMIDITY FREQS";
  obtitle \Freq#1\Table3#1\OneWayFreqs#1 "PLATE FREQS";
  obtitle \Freq#1\Table4#1\OneWayFreqs#1 "FORM FREQS";

  *And here we replay the document with the changes;
  replay ^;
run;

quit;

但这并没有解决错误。谁能帮助我,我在这里缺少什么?

我的参数月份值是整数(1-12)

1 个答案:

答案 0 :(得分:1)

您的问题是:=IIF(Parameters!Month.Value<>1,MonthName(Parameters!Month.Value-1),"December")

我只是在这里猜测,但我怀疑它正在尝试评估MonthName(0)当你传递它时它会导致错误:

我做的是:=MonthName(IIF(Parameters!Month.Value<>1,Parameters!Month.Value-1,12),False).ToString()

它似乎有效。

这也有效:=MonthName(IIF(Parameters!Month.Value<>1,Parameters!Month.Value-1,12))