Grouping on calculated Columns

Stimulsoft Reports.NET discussion
Post Reply
topsys
Posts: 8
Joined: Tue Sep 29, 2009 6:52 am

Grouping on calculated Columns

Post by topsys »

Hi All,
Next problem I have come across converting a crystal report...
I am using a calculated column to generate a field to group some data with. In our crystal report this looks like:

numbervar groupNo;
If trim({command.PND_BARCODE}) = '*SECTION/*'
then groupNo := groupNo +1
else groupNo := groupNo

So nothing special...

This looks in a field for some specific text, everytime it finds this it increments groupNo by one and sets this in the detail section of the report for each record.
The sqlquery that pulls the data in sorts the records by a specific sequence that ensures all items below the '*SECTION/*' are in the correct order.
The resulting data runs correctly in Crystal.

I have re-created the sql statement, created a variable in my report that is an INT with a default value of '0' then created a calulated column to reproduce the Crystal format as follows:

(invoice.PND_BARCODE.Trim() == "*SECTION/*" ? SectionGroupNo = SectionGroupNo + 1: SectionGroupNo)

When I run the report without any grouping, the new Calculated Column is reproducing what I expect correctly,
eg.
GrpNo sqlSequence Code
1 ........ 1 .......... *SECTION/*
1 ........ 2 .......... 1234
1 ........ 3 .......... abc
1 ........ 4 .......... zzz
2 ........ 5 .......... *SECTION/*
2 ........ 6 .......... xxxx
2 ........ 7 .......... 9234

so next I apply a group header, setting this calculated column to be what is used for the grouping and add a group footer below the detail band.

This throws the calculated column way off & it is now no longer performing as expected.
The Calculated column begins not at 1 anymore but at 4 & increments on the correct record, the next after & the one just before in a sequence.
You will notice however that the sqlSequence sort order of the data is still correct
eg
Group Head GrpNo=4
GrpNo sqlSequence Code
5 .......... 1 .......... *SECTION/*

6 .......... 2 .......... 1234
6 .......... 3 .......... abc
7 .......... 4 .......... zzz
Group Head GrpNo=10
GrpNo sqlSequence Code
11 .......... 5 .......... *SECTION/*

12 .......... 6 .......... xxxx
12 .......... 7 .......... 9234

I feel that I have to get the calculated column to be generated before the grouping, but then not be changed after the grouping?
or am I on the wrong track here as to what is going wrong?

Any Ideas?

many thanks in advance
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Grouping on calculated Columns

Post by Edward »

Hi,

It seems that the problem is in the fact that incrementing of the value of variable is in the Calculated column.
The value of the Calculated column is calculated each time when the report engine accesses appropriate datasource in Dictionary.

So using just variables from the Dictionary without using of Calculation columns can resolve the issue, I think.

Could you please send a Crystal report template and mrt report (if possible to send data then it would be great) for analysis to support[at]stimulsoft.com

Thank you.
Post Reply