lmbaptista Posted September 7, 2020 Share Posted September 7, 2020 Hi,I have a table with measures by hour. At the end of the line I have the Total Value by day (Variable)Then I have The global Total (Variable) which is the sum of all Day Totals.In front of each line, I want to have the percentage of that line in the whole month (Global Total). Apparently it should be simple: (TotalValueDay / Global Total ) * 100But no. The results are weird and almost with a descendent pattern, as you can see in teh pic attached.What can be happening to this percentage is not working as it should? Every help will be greatly appreciated.Thanks Link to comment Share on other sites More sharing options...
lmbaptista Posted September 7, 2020 Author Share Posted September 7, 2020 Apparently, it could be related to the order when the variables are calculated. The GlobalTotal is only calculated after all TotalValueDay so it's not possible on day 1 I made a division with the full value.Any ideas to solve this? Link to comment Share on other sites More sharing options...
Sad H Posted September 8, 2020 Share Posted September 8, 2020 what are the type of variables TotalValueDay / Global Total? Link to comment Share on other sites More sharing options...
jgust Posted September 8, 2020 Share Posted September 8, 2020 I'm starting to do some Crystal Reports to Jasper conversions and had to learn how to create an aggregate in the group header. I think the issue is that the GT variable needs to have a reset of MASTER. That will allow Jasper to understand the usage when it is used in an expression. I also read you also have to set the evaluation on the text field to Auto.I created the attached sample report that helped me. It works in Studio 6.14.0 and uses a data adapter called "10 Random Records". Link to comment Share on other sites More sharing options...
lmbaptista Posted September 9, 2020 Author Share Posted September 9, 2020 All variables are Double. Link to comment Share on other sites More sharing options...
lmbaptista Posted September 9, 2020 Author Share Posted September 9, 2020 Thank you for your suggestion, jgust, but unfortunately I couldn't get any results. I tried several options with evaluation time and reset type and none retrieve a good result. The percentage is always calculated on each line, based on the sum of the previous lines and not considering the GlobalTotal. Only the last line will show the correct result because is the only one where the GlobalTotal is the full sum of all values. Link to comment Share on other sites More sharing options...
Sad H Posted September 10, 2020 Share Posted September 10, 2020 Create a variable global Total integer or float type make calculation = none and put expression (TotalValueDay / Global Total ) * 100) in it, change both variable types to integer or float and call global Total , it will work. Link to comment Share on other sites More sharing options...
lmbaptista Posted September 10, 2020 Author Share Posted September 10, 2020 Thank you Sad H, but that was my first approach, but with Doubles since that is the type of my database fields. To do that I need to chanage the type of the fields in the database (to Float) and I don't want to do that.I think the problem is exactly in the order the variables are solved. I just don't know how can I make the GlobalTotal to be the first to be made. Tried to put it in the header but didn't worked. Link to comment Share on other sites More sharing options...
Sad H Posted September 10, 2020 Share Posted September 10, 2020 you want to put globelTotal at header ? am i right? Link to comment Share on other sites More sharing options...
lmbaptista Posted September 10, 2020 Author Share Posted September 10, 2020 Yes. If in the header I can have the GlobalTotal, later in the details, when I need to divide the DailyTotal for the GlobalTotal, that value already exists and hopefullyI solve the problem. Link to comment Share on other sites More sharing options...
Sad H Posted September 10, 2020 Share Posted September 10, 2020 you can create globelTotal and use result it in details at same time, i don't think its a problem. or i have indecent solution for you which is to create subreport and in subreport just perform globelTotal claculation and call it in main report where you want to. 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