Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

modify sample code crosstab % growth

Status
Not open for further replies.

hlmnsbuggy

Technical User
Mar 25, 2002
72
US
CR 11, Oracle data

I found an excellent sample for showing quarterly growth in cross tab. I ran into probelems to modify this code to make yearly? I got error message 'subscript must be between 1 and size of array.' Where can I find to fix that. please be detailed since I am a begineer at this. Secondly, if my date in data is a sting type not datetime type , how can I use GridRowColumnValue


The sample code was shown in one summarized field/ format editor cell/common/display

stringvar columns:= (if Month(GridRowColumnValue ("Orders.Order Date2")) in 1 to 3 then "Quarter 1" else
if Month(GridRowColumnValue ("Orders.Order Date2")) in 4 to 6 then "Quarter 2" else
if Month(GridRowColumnValue ("Orders.Order Date2")) in 7 to 9 then "Quarter 3" else
if Month(GridRowColumnValue ("Orders.Order Date2")) in 10 to 12 then "Quarter 4"); // gridrowcolumnvalue for the cross-tab's column field
global numbervar numrows:= distinctcount({Product_Type.Product Type Name}); // field that the cross-tab rows are based on

stringvar display;
global currencyvar value:= currentfieldvalue;
global currencyvar array allrows;
redim preserve allrows[numrows];

// syntax below finds the row number
global numbervar rv;
global stringvar row;
if columns <> row then rv:=0;
row:= columns;
rv:= rv + 1;
// syntax below finds the column number
global numbervar cv;
global stringvar column;
if columns <> column then cv := cv + 1;
column:= columns;
// syntax below creates an array which calculates row averages
global numbervar array gtrows;
global numbervar rowrt;
global numbervar gtrper;
redim preserve gtrows[numrows];
if allrows[rv] <> 0 then gtrper:= 100*(value-allrows[rv])/allrows[rv];
rowrt:= gtrows[rv] + gtrper;
gtrows[rv]:= rowrt;
// syntax below creates an array which calculates column averages
global numbervar array gtcolumns;
global numbervar columnrt;
global numbervar gtcper;
redim preserve gtcolumns[numrows];
if allrows[rv] <> 0 then gtcper:= 100*(value-allrows[rv])/allrows[rv];
columnrt:= gtcolumns[cv] + gtcper;
gtcolumns[cv]:= columnrt;
// syntax below creates variables that will be used in the grand total average
global numbervar gtavg;
global numbervar gtctr;
if cv > 1 and allrows[rv] <> 0 then gtavg:= gtavg + 100*(value-allrows[rv])/allrows[rv] else gtavg := gtavg;
if cv > 1 then gtctr:= gtctr + 1;
// syntax below creates the display for this summary
if cv > 1 and allrows[rv] <> 0 then display := totext(100*(value-allrows[rv])/allrows[rv],0)+"%" else display:= "n/a ";
allrows[rv]:= value;

display;


Please adivce
Ann
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top