Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Reading an Array Post Reply Post New Topic
Author Message
jkaufman
Newbie
Newbie


Joined: 20 May 2009
Location: United States
Online Status: Offline
Posts: 7
Quote jkaufman Replybullet Topic: Reading an Array
     Posted: 20 May 2009 at 7:01am
 Hi,

I am drilling into a table in our software and the field is an array.  I am using Crystal XI.

The data held there is sales numbers for each month.  I want to be able to for any month of my choosing be able to pull the data that relates to that particular month.  So in the data below, if I wanted the sales for April, I would get as a result 35865.9.


0;0;0;35865.9;68436.95;0;0;0;0;0;0;0;0
(This data array is in field name 'dollars-shipped')


I will be manipulating that data to determine margins and cost of goods, so would need to be able to use this Array Read in formulas too.

 Thanks for your help! 

Edited by jkaufman - 20 May 2009 at 7:17am
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 20 May 2009 at 7:06am
isn't stored as a group of rows in the database?  Crystal is either going to connect the database or to a dataset that you provide, and would be looking at rows.  If it is stored as a delimited string in the database, then I would just loop through the string getting rid of the months that you don't want keeping what you do.
 
to make things simple I would look for ";", so I would add one to the end of the string.
 
IP IP Logged
jkaufman
Newbie
Newbie


Joined: 20 May 2009
Location: United States
Online Status: Offline
Posts: 7
Quote jkaufman Replybullet Posted: 20 May 2009 at 7:21am
I am not sure if that would work, as the array data is a field within a table, unless i did a formula to add the semi colon to end of the field.

But as I want this report to be run each week throughout the year, it would need be able to read whichever month I chose and i have limited knowledge of using loops.

EDIT:

i received an answer on a different forum and it works great, but wanted to post it here for anyone who may stumble across this post.

 create a formula as below with a parameter {?Month Selection} as below

local stringvar array x;
x:=split({oe_hist_cust.dollars-shipped}, ";");
tonumber(x[{?Month Selection}]);


Edited by jkaufman - 20 May 2009 at 8:12am
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 20 May 2009 at 10:32am
hadn't thought about split, but that would definitely work
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