Normal Topic Report Programming: Sum Calculation Formula? (Read 930 times)
actiontech
Full Member
***
Offline



Posts: 173
Joined: Apr 10th, 2016
Report Programming: Sum Calculation Formula?
Apr 27th, 2016 at 5:58pm
Print Post Print Post  
Is it possible for Sesame Reports "Sum Calculations" to do more than just add/etc.? For example, can their be programming set that causes it to carry out a specific formula, such as, (a - b) * c = d and d = Sum?

If it is possible, does anyone know how to do so?
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Report Programming: Sum Calculation Formula?
Reply #1 - Apr 28th, 2016 at 3:33pm
Print Post Print Post  
You can add unbound value boxes to the reports and program them to do any math that you want(Except divide by Zero as that is impossible) If you add an unbound value box named D to the Group Body of your report, and want to perform the equation that you listed, the programming would simply be

D = (A-B) * C

You will want to format the D element as a Number or Money value, which will not only apply formatting to it but allow that value in the group body to be Summed by calculation boxes in the group footer.

If you are trying to do math on the result of Summary Calculations that becomes a bit more difficult as the Summary Calculations happen AFTER programming happens so that they can sum calculated values. In this case what you do is have duplicate Summary Calculations elements in a group footer directly BEFORE the one you are working in. Set them to be invisible. Then in the one you are working in, add an unbound value box, format it as the appropriate numerical type, and program it to perform the calculation using the element names of the Summary Calculations elements in the group footer above.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
actiontech
Full Member
***
Offline



Posts: 173
Joined: Apr 10th, 2016
Re: Report Programming: Sum Calculation Formula?
Reply #2 - May 9th, 2016 at 1:18pm
Print Post Print Post  
If I'm getting this right, it sounds like you're saying. It's better to just forget the summary calculation element, and just create an unbound value element with good/correct programming, that will do the exact same thing but more efficiently?
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Report Programming: Sum Calculation Formula?
Reply #3 - May 9th, 2016 at 3:54pm
Print Post Print Post  
It isn't an issue of efficiency. Its a matter of flexibility. Because you cannot set the formula, like you can in programming, they are less flexible. They end up being a lot more efficient, in that they are run in compiled C, rather than interpreted SBasic.

So, if your formula is simple enough (sum, average, etc.) a summary calc is going to run faster and use far fewer resources. But if you need a custom formula, you can implement anything you might need in SBasic. They can also work together in combination, as Ray made clear - with some caveats.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
actiontech
Full Member
***
Offline



Posts: 173
Joined: Apr 10th, 2016
Re: Report Programming: Sum Calculation Formula?
Reply #4 - May 11th, 2016 at 12:46pm
Print Post Print Post  
Interesting, thanks.
  
Back to top
 
IP Logged