Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: return range of values Post Reply Post New Topic
Author Message
c16271
Groupie
Groupie
Avatar

Joined: 24 Aug 2010
Location: United States
Online Status: Offline
Posts: 48
Quote c16271 Replybullet Topic: return range of values
     Posted: 19 Dec 2011 at 7:43am
Crystal Reports Version: XI
Database: Oracle 10gR2
 
Issue:
I'm having an issue writing the following loop structure:
 
Intent:
 
I need the formula to return inclusive range for the conditions below. Currently, {@max_wrk_week} - {@min_wrk_week} are calculated using the MAXIMUM and MINIMUM functions against the data set. The formula is only returning 1148
 
Max = 1148
Min  = 1144
Maxi = 4;
 
//formula groupie
WhilePrintingRecords;
Local NumberVar maxi := {@max_wrk_week} - {@min_wrk_week};
Local NumberVar ref;
Local NumberVar i;
For i:= 1 TO maxi
DO
(
    ref := {@min_wrk_week} + i;
);
ref;
 
Please let me know if this is unclear, I'll be working on the issue. I'll post solution if I get there before I get some help...
 
 
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 19 Dec 2011 at 12:13pm
the formula only 'displays' the value once...at the end.
 
you could try adding to a string and displaying the string
 
unfortunately, the code is performing what you told it to do... (hilfy's tag line)
 
HTH
IP IP Logged
c16271
Groupie
Groupie
Avatar

Joined: 24 Aug 2010
Location: United States
Online Status: Offline
Posts: 48
Quote c16271 Replybullet Posted: 19 Dec 2011 at 12:22pm
I added the following to the function; however, I'm still geting 1148 :(
Is there  a different way of doing this? I eventually want to group the data by the results of this fuction, if possible:

WhilePrintingRecords;
Local NumberVar maxi := {@max_wrk_week} - {@min_wrk_week};

Local NumberVar ref;
Local StringVar output;
Local NumberVar i;
For i:= 1 TO maxi
DO
(
    ref := {@min_wrk_week} + i;
    output := ToText(ref);
);

output;

IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 23 Dec 2011 at 3:35am
probably can't group by this formula.
 
CR will only group on a formula if it can evaluate the formula in one read of the data, with no other dependencies.
 
for example, if you have a date, you can group on the day of week of the date, or if you have 2 columns, CR can contenate the columns or subtract the columns or check if a value is contained in the columns...or maybe, if the previous or next record have some value, but it needs the formula to be answered without having to read outside of the current record.
 
At least that is what the rule seems to be.
 
I am guessing that you are expecting multiple values to display...
If so, I would expect the code to look something like:
output := output + ", " + ToText(ref);
 
HTH
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum