Problem with variable sum

1

Hi,

I'm working with java 8 and jasper studio 6.3.1.

I have 2 types of rows of textfields on different colums like Total Price, Price w/o Taxes, Discounts%, etc. The first type of row has different amount of rows, for each report, and the variables with the price of a product, taking it from the database. And the 2d type of row is just one row with the sum of all the rows of the first type. 

For example: 
          Total Price -   Price w/o Taxes   -   Discounts%
 XArticle: 5€     -          4€              -      20%
 YArticle:  7€     -          6€              -     15%
    Totals:  12€    -         10€

Now, the 2 variables (one for the lines and other for the final total).

i.e: $V{total_sum_taxes_line}, where the variable values are:

   Value Class Name: java.lang.Double
   Calculation: No calculation
   Expression: $F{Containers}*$F{ContainerPrice}*$F{TAX}
   Initial Value Expresion: new Double(0)
   Increment type: None
   Reset type: Group1 (The group where the field is)

 

It multiplies the amount of containers for its price and the taxes, giving you 5 (for example).

 

Now I have other variables for the 2nd type of row, that sums the total prices and gives you 12€.

Theorically, it should be super easy, and this variable is: $V{Total_Final_Sum}:
   Value Class Name: java.lang.Double
   Calculation: SUM
   Expression: $V{total_sum_taxes_line}  (The variable for each line)
   Initial Value Expresion: new Double(0)
   Increment type: None
   Reset type: Report (Coz I only want it once, at the end)

Now, I have it exactly like this for different columns, one has the value of each line and the other has the final sum of all the lines, but it works only for some of the columns.

In other colums, it shows random values that are clearly not correct.

I've tried changing the calculation, the initial value, and the reset type, any of those worked. 
I also tried changing the expression of the final sum, and instead of putting the lines variable, I tried putting the calculation with the field from the database:
   $F{Containers}*$F{ContainerPrice}*$F{TAX}

But it still doesnt work, and I don't know why. 

 

 

 

gabrieltcb's picture
Joined: Oct 24 2019 - 1:32am
Last seen: 3 days 12 hours ago

4 Answers:

1

Hi Gabriel :')

try step below :
- add header footer if ure using table component
- drag the field to header footer and it will popup a menu, u want to choose summary
- try execute the report, it should show the summary of the data u rendered

else u want to test first? drag any field to any other than detail band in ur report then choose summary.
it should render the total of the field.

else u hv complicated one which the total is based on each group.
in ur case the group is S.L.U, then if u render ex. S.L.A u want the total is based on the data shown in S.L.A group
u might need to change the Reset type.

hope u did well ! - TV

trvpseudo's picture
Joined: Jan 30 2019 - 11:02pm
Last seen: 2 days 16 hours ago
1

Hi TV

Thanks for answering, and yep, my name is gabriel, why is it weird?

So, that's what I have at the moment, and that's the way it's supposed to be done (I thought).

 The red rows (is one row in jasper) is a variable on a textfield that calculates some values, it works properly.
 The blue row has the final variables, and they have the configuration you've said.


 It's a variable inside a textfield on the page footer, the "Calculation" property is set as summary, and the "Expression" has the name of the variable they are suppposed to sum. (The one colored in blue has in the expression the variable used in the red row).
It works properly for some columns, as you can check by summing it (for example "Descuento Labor"), but it doesn't for the ones circled in blue.

I've already tried changing the "Reset type" to Report, Page, or Group, but none of those work.
I've also tried summing values from my database coz I cannot understand where the "114,16€" comes from, it doesn't make any sense to me.

Thank you for your answer TV :). I'll try for a little while, if I find the answer I'll put in on here.

Gaby :)

Attachments: 
AttachmentSize
Image icon jasperbugs.png23.5 KB
gabrieltcb's picture
Joined: Oct 24 2019 - 1:32am
Last seen: 3 days 12 hours ago
1

hi Gaby,
not weird, its just.. theres someone special similar to ur name :')

anyway XD
sometimes works from scratch did the magic!
delete the variable, just use field. when u drag there, in the popup choose sum option

welp, i did try some cases before telling others the way and it seems fine (including using variable instead of field), but prob not this one :/
no worries, eventually ull get use to it through experiment.
i once stuck on something for 3weeks without a clue lol
hope u did well asap El :D

regards - TV

trvpseudo's picture
Joined: Jan 30 2019 - 11:02pm
Last seen: 2 days 16 hours ago
1

Hi TV,
I suppose it's not a common name.But I hope it's special in the good and not the sad way :')

The thing is, when you drag a field into the report and select something from the popup options, actually it's: creating a textField, a variable with the "Calculation" property set as the one you choose, and then inserting the variable into the textfield, automatiaclly.

I don't mind getting stuck on something for too long, as long as I'm really working/learning and going forward.
Now I was stuck and we just jump to other tasks. Anyway I try to continually read this forum even if I'm not with a jasper/report tasks

Thank you for answering and trying to look for the answer with me,
How is it working and why it's not working for me is a mistery (that newbies like me cannot cmoprehend, yet)

Gaby :)

gabrieltcb's picture
Joined: Oct 24 2019 - 1:32am
Last seen: 3 days 12 hours ago
Feedback