Domanda

I'm having problem with JasperReports report by getting sum of two fields.
I have created so far variables that holds fields "TareWeight" variable that is casting values from double to float

new Float($F{EquipmentTareWeightKg})

"CargoWt" variable that is casting from string to float, etc...

Float.parseFloat($F{UfvFlexString03})+Float.parseFloat($F{UfvFlexString04})

So now I have two variables which I can manipulate with.
The problem starts when I wish to do a "recap" using crosstab. I have setup two groups that is done with wizard, and added another in crosstab. (please refer to the printscreen below)

iReport crosstab design

And now, I have created under measures SumOf Tare that is using variable TareWt, and SumOfCargoWt that is using variable CargoWt.

I have tried to create another Measure SumOfGrossWt that would do a sum of variables TareWt + CargoWt but I have got some nonsense values.

I have tried to do another approach by creating variable GrossWt that would basically do exact the same thing as previous attempt

$V{Tare}+$V{CargoWt}

or use an variable: GrossWt

$V{Tare}+$V{CargoWt} or new Float($F{EquipmentTareWeightKg})+(Float.parseFloat($F{UfvFlexString03})+Float.parseFloat($F{UfvFlexString04}))

None of these actually worked: (Sum should be done by "Sum Of Tare"+ "Sum of CargoWt" = "Sum of GrossWt") plese refer to the second picture.

iReport preview and wrong calculation

Here is a complete jrxml code/file:

jrxml file

save it as *.jrxml

Can please someone help me find a solution? how can I sum those two measure fields and get correct values?

È stato utile?

Soluzione

Since CargoWt field had some null values in database, addition float value with null is equal to null, so the only value which was displayed on report are the one that had values for CargoWt, all others with null value were "ignored".

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top