Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Static columns for crosstabs

edited November 2006 in General
I am trying to create static colums using a crosstabs. I pattern mine after
demo ct125. I am also trying to checking several field in the pipeline and
verify the value. Is it possible to check the values of the pipleline if
the fields are not a Dimension. A partial lising is below

the error I'm receiving is. I'm using ver 6.02


I and receiving a "List index out of bounds(1).



procedure TfrmJailBookReports2.ppCrossTabGetDimensionName(Sender: TObject;
aDimension: TppDimension; var aName: String);
begin

if(aDimension = TppCrossTab(Sender).ValueDefs[0]) then
aName := 'SENTENCED (365 days or more)'
else if (aDimension = TppCrossTab(Sender).ValueDefs[1]) then
aName := 'SENTENCED (364 days or less)'
else if (aDimension = TppCrossTab(Sender).ValueDefs[2]) then
aName := 'AWAITING TRIAL'
else if (aDimension = TppCrossTab(Sender).ValueDefs[3]) then
aName := 'AWAITING SENTENCING'
else if (aDimension = TppCrossTab(Sender).ValueDefs[4]) then
aName := 'PROBATION VIOLATORS (technical)'
else if(aDimension = TppCrossTab(Sender).ValueDefs[5]) then
aName := 'SENTENCED (365 days or more)'

and

procedure TfrmJailBookReports2.ppCrossTabCalcDimensionValue(
Sender: TObject; aDimension: TppDimension; var aValue: Variant);
var
lValueDef: TppValueDef;
lValue: variant;
lAdultValue: variant;
lSexValue: variant;
lCaseTypeValue: variant;
lCrossTab: TppCrossTab;

begin
if not (aDimension is TppValueDef) then exit;

lValueDef := TppValueDef(aDimension);

//if (lValueDef.CalcType <> dcCount) then Exit;

lCrossTab := TppCrossTab(Sender);

lValue := lCrossTab.DataPipeline['Status'];
lSexValue := lCrossTab.DataPipeline['Sex'];
lAdultValue := lCrossTab.DataPipeline['Adult'];
lCaseTypeValue := lCrossTab.DataPipeline['Case_Level_Type'];

{ Felony Males Adults}
if (lValueDef = lCrossTab.ValueDefs[0]) and (lSexValue = 'M') and
(BoolToStr(lAdultvalue,True) = 'TRUE') and (lCaseTypeValue = 1) and
(lValue = 'SFF')then
aValue := aValue + 1;
if (lValueDef = lCrossTab.ValueDefs[1]) and (lSexValue = 'M') and
(BoolToStr(lAdultvalue,True) = 'TRUE') and (lCaseTypeValue = 1) and
(lValue = 'SF')then
aValue := aValue + 1;
if (lValueDef = lCrossTab.ValueDefs[2]) and (lSexValue = 'M') and
(BoolToStr(lAdultvalue,True) = 'TRUE') and (lCaseTypeValue = 1) and
(lValue = 'FAT')then
aValue := aValue + 1;
if (lValueDef = lCrossTab.ValueDefs[3]) and (lSexValue = 'M') and
(BoolToStr(lAdultvalue,True) = 'TRUE') and (lCaseTypeValue = 1) and
(lValue = 'FAS')then
aValue := aValue + 1;
if (lValueDef = lCrossTab.ValueDefs[4]) and (lSexValue = 'M') and
(BoolToStr(lAdultvalue,True) = 'TRUE') and (lCaseTypeValue = 1) and
(lValue = 'FVOP')then
aValue := aValue + 1;
{ Misdemeanor Males Adults}
if (lValueDef = lCrossTab.ValueDefs[5]) and (lSexValue = 'M') and
(BoolToStr(lAdultvalue,True) = 'TRUE') and (lCaseTypeValue = 1) and
(lValue = 'SM')then
aValue := aValue + 1;
if (lValueDef = lCrossTab.ValueDefs[6]) and (lSexValue = 'M') and
(BoolToStr(lAdultvalue,True) = 'TRUE') and (lCaseTypeValue = 1) and
(lValue = 'SMM')then
aValue := aValue + 1;

Comments

  • edited November 2006
    Hi Colton,

    I would first recommend that you consider upgrading to the latest version of
    ReportBuilder for your version of Delphi.

    If you trace into the code below, where is the error occuring. My guess
    would be that your crosstab does not contain the amount of dimentions or
    calc dimentions you are checking for. You may want to check the
    ValueDefs.Count before hard coding the number.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited December 2006
    Yes you are correct, that was the problem. One other thing I'm having a
    problem with is that I'm trying to get an accurate count for each dimension
    and based on certain conditions. The code below has examples on what I'm
    trying to accomplish. Each is coming back with a total as though the
    conditions are not being observed.

    Also I am unable to change from count to sum for a dimension


  • edited December 2006
    Hi Colton,

    Try tracing your code and see if the data for lValue, lSexValue, etc. are
    actually changing for each record the crosstab is traversing. Also, be sure
    the boolean to string conversion is being properly utilized.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited December 2006
    Ok I am getting values, but calculation are wrong. It seems that I'm
    getting value for the count of all records during the time period instead of
    the selective counts .


  • edited December 2006
    Hi Colton,

    My guess is that you need to check the value of aValue before you alter it.
    The purpose of this event is to take the calculated value and perform more
    calculations or completely ignore the built-in calculations and perform your
    own (resetting the aValue parameter). I'm a bit unclear about what exactly
    you would like your crosstab to look like. Remember that this event is
    going to fire for every dimention in the crosstab. If you are looking to
    get a count of individual sections of the crosstab, you might consider
    creating a separate variable to hold this value.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.