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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Position of data within a string

Status
Not open for further replies.

JasonKaufman

Programmer
Apr 13, 2006
46
US
I am using Crystal XI

I am wanting to create a report that takes the db string of data and looks at each section of the string and determines the position within the string (for eventual numerical month value) of the section.

So when it looks at the data below, it would see the first section (789.6) and indicate that this is "1", "2" (211.5) and so forth for each part of the string.

Keep in mind that once this formula is created, I will be wanting to create a new header with this new month formula so all product sold in that month will appear.

789.6;211.5;479.4;1170.3;944.7;1099.8;1198.5;1123.2;1641.6;3542.4;187.2;259.2;0


This is the formula that I am using now to pull out the data

(local stringvar array x;
x:=split({oe_hist_prod.dollars-shipped}, ";");
(x[1]);)


Thanks for the help!
 
I actually meant the values are from an Array , not a string.
 
What is the problem you are encountering?

-LB
 
Each segment of numerical data that is separated by a semicolon is a month's worth of data (Jan-Dec).

I don't know how to call out the position of each month of data in the array and have it appear as 1,2,3,4,5,6 etc using a formula. So when the formula sees 789.6 would be 1, 479.4 is 2, 1170.3 is 3 etc.

[789.6;211.5;479.4;1170.3;944.7;1099.8;1198.5;1123.2;1641.6;3542.4;187.2;259.2;0]

The formula I presented is one I am using to draw out the value that is within any given month. This is given more as a reference.
 
stringvar x := {table.yourfield};
stringvar array y := split(x,";");
numbervar i;
numbervar j := ubound(y);
numbervar array cnt;
for i := 1 to j do(
redim preserve cnt[j];
cnt := i;
);
cnt[7] //to show "7" for 7th element

-LB
 
LB,
thanks for the formula! I never would have considered all of that...
While this does allow me to indicate which position I want to look at when I choose: "cnt[7] //to show "7" for 7th element" where 7 could be any number between 1-13

What I have envisioned is to have either this formula or a subsequent one allow me to generate all 12 monthly element positions of the array at one time so that the report would look something like:

1
prod1 prod1$
prod2 prod2$
prod3 prod3$

2
prod1 prod1$
prod2 prod2$
prod3 prod3$
.
.
.
12
prod1 prod1$
prod2 prod2$
prod3 prod3$

here [1, 2,...12] are the positions of the array elements.

I was able to modify my prod$ formula to incorporate your formula thus I can at the very least go month by month to generate my data. The formula follows:

(local stringvar array x;
x:=split({oe_hist_prod.dollars-shipped}, ";");
tonumber(x[{@Month}]);) -
(local stringvar array x;
x:=split({oe_hist_prod.dollars-returned}, ";");
tonumber(x[{@Month}]);)
//where {@Month} = your formula with whatever cnt # I choose.

I hope I am not being muddy in what I am striving for...if you have any other questions or ideas, they are welcome.
Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top