Jump to content
We've recently updated our Privacy Statement, available here ×

Creating a percentage between variables is not working properly


lmbaptista

Recommended Posts

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 ) * 100

But 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

  • Replies 10
  • Created
  • Last Reply

Top Posters In This Topic

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

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...