gabrieltcb Posted December 2, 2019 Share Posted December 2, 2019 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. Link to comment Share on other sites More sharing options...
trvpseudo Posted December 4, 2019 Share Posted December 4, 2019 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 renderedelse 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 groupu might need to change the Reset type.hope u did well ! - TV Link to comment Share on other sites More sharing options...
gabrieltcb Posted December 4, 2019 Author Share Posted December 4, 2019 Hi TVThanks 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 :) Link to comment Share on other sites More sharing options...
trvpseudo Posted December 5, 2019 Share Posted December 5, 2019 hi Gaby,not weird, its just.. theres someone special similar to ur name :')anyway XDsometimes works from scratch did the magic!delete the variable, just use field. when u drag there, in the popup choose sum optionwelp, 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 lolhope u did well asap El :Dregards - TV Link to comment Share on other sites More sharing options...
gabrieltcb Posted December 5, 2019 Author Share Posted December 5, 2019 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 tasksThank 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 :) Link to comment Share on other sites More sharing options...
hondaman900 Posted January 16, 2021 Share Posted January 16, 2021 Hi Gaby,Did you ever resolve this? I'm in the same boat where I have a variable displaying a correct number per row in a group, and another variable in the footer of the group set to simply sum the line variable with reset type group. The summary result is wrong and I've literally spent a week going over this and can't find the reason why it's giving a wrong answer. It's not a rounding or missing number, just a significantly different one.The correct result is -$50,166 and the missing 3,644 is not related to anything I can find.Any info on what you ended up doing to resolve this would be very helpful. Thanks in advance. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now