Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Calculating a Number in a Cross-Tab

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?

The array formula is:


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;



// 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?


Former Member

hi Trey,

since you're using the Display String in your first summary you need to assign the displayed value to a variable. i.e. change the Display String formula to


stringvar t:= GridRowColumnValue ("rpt_EquipmentMaster.Description");

stringvar array ad;

numbervar array ap;

numbervar c3:= 1;

numbervar n2;

while c3 <= count(ad) do


        if t = ad[c3] then (n2 := c3; exit while);

        c3 := c3 + 1


numbervar apn:= ap[n2];


once that is done, you now have a variable (apn) that is available on the row level for your summaries.

once you've added the unit cost field as a Maximum type summary to your cross-tab as the second summary, right click on that summary and go to the display string for unit cost maximum. enter in this syntax:


numbervar apn;

numbervar apnrt:= apnrt + apn*currentfieldvalue;

totext(currentfieldvalue * apn,0)

note that you're referencing the variable apn which is used in the output of the previous summary. also note that you're creating another running total named apnrt which runs in the background of the cross-tab. you'll need this running total for the grand total in the cross-tab.

now right click on the grand total for the maximum unit cost summary and go to the display string for this value. enter in this syntax.


numbervar apnrt;

totext(apnrt, 0)

0 View this answer in context

Helpful Answer

Not what you were looking for? View more on this topic or Ask a question