Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9067

Calculating a Number in a Cross-Tab

$
0
0

Not sure the best way to explain this one, but I was helped to create a cross-tab that used an array to calculate the number of incentives and summarize the result in a cross-tab.  Now I'm looking to take this number and multiple it by another column in a table {UnitCost} to calculate the total value of the incentives used for the report.


The previous issue was here:

Problems with running totals

 

For instance, if the units costs are as follows:

Double Fandango = 10

Fandango = 5

Gift Card $10 = 10

Movie Ticket = 5

 

I would like to cross tab to look like the attached picture.  Would this be possible?

IncentiveCosts.JPG

 

The array formula is:

whileprintingrecords;

 

stringvar d:= {OBI_EquipmentMaster.Description};

numbervar p:= {DriveProjectionAndCollectedTotals.ProcedureProjection};

numbervar pe:= {DriveProjectionAndCollectedTotals.ProceduresPerformed};

 

stringvar array ad;

numbervar array ap;

numbervar array ape;

numbervar c2:= 1;

numbervar n:=0;

 

// check to see if the description has been added to the string array

// if not, add it plus add the initial projection value to the number arrays

if not (d in ad) then

    (

        numbervar c:= c + 1;

        redim preserve ad[c]; ad[c]:= d;

        redim preserve ap[c]; ap[c]:= p;

        redim preserve ape[c]; ape[c]:= pe;

    )

 

else

 

// if the description is already in the array, find its position

// then add the new projection as a running total to the appropriate number array values

(

    while c2 <= count(ad) do

        (

            if d = ad[c2] then (n := c2; exit while);

            c2 := c2 + 1

        );

    ap[n]:= ap[n] + p;

    ape[n]:= ape[n] + pe;

);

 

 

// grand running totals

numbervar gp:= gp + p;

numbervar gpe:= gpe + pe;

 

I thought it would be a start creating a new number variable:

numbervar i:= {OBI_EquipmentMaster.UnitCost}

 

But I'm not sure I understand the rest of the formula nor how to insert a new column in the cross-tab.  Any suggestions on how to proceed?

 

Thanks,


Viewing all articles
Browse latest Browse all 9067

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>