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

problem with arrays in formulas

Status
Not open for further replies.

ub1234567

Programmer
Dec 4, 2008
69
US
Hi everyone,

i am beginners in crystal XI.

i have one problem with arrays in formula.

my columns displays is like this --

column1
2001
2001
2001
2001
2002
2002
2003
2003
2003
2004
2004

actually i want to display distinct years in ascending order.
i have one logic that i can use current raw and compare with next raw year using next function.
but when there is a differant year in two consecutive raw then i want to store that raw year in one array formula.

so that at the end i can put that formula in report footer section so
it display distinct year in ascending order.

any help is appriciated.
 
You can group on years, and also do totals for the group.

If you're wanting to compare the totals for years, that is harder. The easiest way is to have a set of running totals, one for each year. But note that they won't have the correct totals until after all of the data has been printed.

If you're not already familiar with Crystal's automated totals, see FAQ767-6524.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Place a formula like the following in the detail section:

whileprintingrecords;
stringvar array x;
numbervar i;
numbervar j := distinctcount({table.year});
if not (totext({table.year},0,"") in x then (
i := i + 1;
redim preserve x[j];
x := totext({table.year},0,"")
);

Then in the report footer, use a formula like this:

whileprintingrecords;
stringvar array x;
join(x,", ")

-LB
 
hi Lbass,

thanks for given me reply.

if not (totext({table.year},0,"") in x

but in above statement, there is no value in X.
how if part looking for value in variable x ?

numbervar i;

and also do we need to assign initial value ot i variable ?

like numbervar i = 0;

your help is appriciated
thanks.

 
All you need to do is substitute your year field for {table.field} and the formulas should work as is.

Re: the clause: if not(.....in x), x has a value after the first record, and this is how you only add distinct values.

You do not need any initialization formulas.

-LB

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top