Pentaho Report Designer中substring的语法是什么?

时间:2013-11-19 15:24:01

标签: pentaho

我正在尝试设置字符串字段的bg颜色,以便如果字段的值以“R”开头,则将背景颜色设置为红色。当值为“R080”时,以下表达式可正常工作:

=IF([Scored_Individual]="R080"; "#FF0000"; "#FFFFFF")

当[Scored_Individual]以'R'开头时,我想将此更改为true。我发现有一个subString函数,但是仍然要写这个文档:http://wiki.pentaho.com/display/Reporting/SubStringExpression

我尝试了以下内容:

  • =IF([Scored_Individual].substring(0)="R"; "#FF0000"; "#FFFFFF")
  • =IF([Scored_Individual].substring(1)="R"; "#FF0000"; "#FFFFFF")
  • =IF([Scored_Individual].substring(0,1)="R"; "#FF0000"; "#FFFFFF")
  • =IF([Scored_Individual].substring(0)='R'; "#FF0000"; "#FFFFFF")
  • =IF([Scored_Individual].substring(1)='R'; "#FF0000"; "#FFFFFF")
  • =IF([Scored_Individual].substring(0,1)='R'; "#FF0000"; "#FFFFFF")
  • =IF([Scored_Individual].subString(0)="R"; "#FF0000"; "#FFFFFF")
  • =IF([Scored_Individual].subString(1)="R"; "#FF0000"; "#FFFFFF")
  • =IF([Scored_Individual].subString(0,1)="R"; "#FF0000"; "#FFFFFF")
  • =IF([Scored_Individual].subString(0)='R'; "#FF0000"; "#FFFFFF")
  • =IF([Scored_Individual].subString(1)='R'; "#FF0000"; "#FFFFFF")
  • =IF([Scored_Individual].subString(0,1)='R'; "#FF0000"; "#FFFFFF")

以及上述所有内容,但使用==而不是=

我也试过使用左:

  • =IF([Scored_Individual].left(0)="R"; "#FF0000"; "#FFFFFF")
  • =IF([Scored_Individual].left(1)="R"; "#FF0000"; "#FFFFFF")
  • =IF([Scored_Individual].left(0)='R'; "#FF0000"; "#FFFFFF")
  • =IF([Scored_Individual].left(1)='R'; "#FF0000"; "#FFFFFF")
  • =IF([Scored_Individual].left(0)=="R"; "#FF0000"; "#FFFFFF")
  • =IF([Scored_Individual].left(1)=="R"; "#FF0000"; "#FFFFFF")
  • =IF([Scored_Individual].left(0)=='R'; "#FF0000"; "#FFFFFF")
  • =IF([Scored_Individual].left(1)=='R'; "#FF0000"; "#FFFFFF")

这些都没有奏效。你如何使用子串?有更好的方法吗?

1 个答案:

答案 0 :(得分:1)

PRD使用OpenFormula,它基于LibreOffice和Openoffice使用的电子表格公式。因此,您使用与OpenOffice(或Excel)相同的逻辑。

=IF(LEFT([Scored_individual]; 1) = "R"; "#FF0000"; "#FFFFFF")