Normal Topic Math calculation for derived column in Report (Read 529 times)
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Math calculation for derived column in Report
Jan 13th, 2012 at 7:41pm
Print Post Print Post  
Backdrop:  Report that summarizes sales and profits for a given period of time.

Dilemma:  I have created a value box (number) in order to calculate the margin % of each item category, but cannot get it to 'find' the derived total $revenue amount and the derived total $profit field so that it can make the calculation.

Example of output of the current report:
Category             Revenue                   Profit         Margin
54                   $25,005.12            $4,691.08       ??
                                                           
                                   
54W                   $20,828.56            $9,853.11       ??
                                                           
                                   
56                   $19,088.43            $3,607.28       ??


And here is the programming in the MarginPerc value box (that returns "1" in each row ... I put the last line of programming in there to try and determine if I was reaching the intended data (which I'm not)

var vMarg as double
var vProfit as double
var vCatRevenue as double

vMarg = 0
vProfit = 0
vCatRevenue = 0

vProfit = LIProfitTotalItemCatUmb
vCatRevenue = GF_0_COL_4

MarginPerc = @TN(vCatRevenue)


If (@TN(vProfit) > 0) and (@TN(vCatRevenue) > 0)
  {
     vMarg = ((@TN(vProfit))/(@TN(vCatRevenue)))
     vMarg = 100 * @TN(vMarg)
     MarginPerc = @TN(vMarg)
  }
    else {MarginPerc = 1}
  

Larry
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: Math calculation for derived column in Report
Reply #1 - Jan 13th, 2012 at 8:30pm
Print Post Print Post  
Hello lksseven,

At the time Programming runs the Summary calculation elements such as Sum, do not have their values yet. So what you'll need to do is this.

Add another Group after the matching Header for the footer where you have your Summary calculations. (So if your sum boxes are in Group Footer 4, add a new Group after Group Header 4)
In the new group footer, add a Sum box that sums Revenue and a Sum box that sums Profit.
Set them both to be invisible.
In your programming simply reference the newly added sum elements that were just added in the Footer above this one.

-Ray
  

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



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Re: Math calculation for derived column in Report
Reply #2 - Jan 13th, 2012 at 10:18pm
Print Post Print Post  
Hi Ray,

I haven't spent a lot of time learning the Report Writer (obviously), and haven't 'added a group' before.  I'll implement your instruction this weekend.

Thank you.
  

Larry
Back to top
IP Logged
 
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Re: Math calculation for derived column in Report
Reply #3 - Jan 13th, 2012 at 10:37pm
Print Post Print Post  
THAT worked like a charm.   Thanks, Ray.
  

Larry
Back to top
IP Logged