2014-05-05 17 views
1

如何計算地址字段爲空(或任何其他值)的地方有多少行,然後在摘要帶中打印總數?計算字段爲特定值的行數

我試過使用變量,但似乎無法得到它的工作。

  • 的JasperServer 5.0.1
  • iReport的5.5.0

回答

1

添加一個變量具有這些屬性:

Variable class : java.lang.Integer 
Caculation : Sum 
Reset Type : Report 
Increment type : Group 
Increment group : YourGroupName 
Variable expression : $F{yourField}.equals("") ? 0 : 1 
+1

使用' 「」 .equals($ F {} yourField)'以避免潛在的NullPointerException異常。 –

3

聲明變量$V{countNull}與屬性:

Variable class = java.lang.Integer 
Calculation = Sum 
ResetType = Report 
Increment type = None 
Variable expression = $F{address} != null ? 0 : 1 

$V{countNull}摘要頻帶。

$V{countNull}代入詳細說明帶看它的計算(用於調試)。