I am using Crystal 8.0 which connects to my db via ODBC. I have a field with multiple values separated by commas. What I want to end up with is a cross tab.
data:
record1: product1, product2, product3
record2: product3, product4, product5, product6
record3: product1, product6
record4: product7
record5: product5, product2
5 records
7 distinct products
12 products total
my desired result:
product1 2
product2 2
product3 2
product4 1
product5 2
product6 2
product7 1
total 12
I've used the split function to get the count of 12 products in another part of the report. I also have local variables for each of the 7 products.
In the crosstab row formula, I have if-then-else statements set up as follows:
if varproduct1=1 then "product1" else
if varproduct2=1 then "product2" else
if varproduct3=1 then "product3" else
if varproduct4=1 then "product4" else
if varproduct5=1 then "product5" else
if varproduct6=1 then "product6" else
if varproduct7=1 then "product7" else
"unknownproduct"
what I'm actually getting:
product1 2
product2
product3 1
product4
product5 1
product6
product7 1
unknownproduct 7
total 12
This is my problem. When Crystal finds product1 in the record, it then goes to the end. It doesn't CONTINUE reading the record to see if that record satisfies any of the other ifs. I know, that's how if-then-else statements work.
How can I get Crystal to read the record multiple times so that it will count all 12 of the products and put them in the correct line of the cross tab? I have a feeling an array is involved somewhere, but I don’t know exactly how. Can anyone help me?
data:
record1: product1, product2, product3
record2: product3, product4, product5, product6
record3: product1, product6
record4: product7
record5: product5, product2
5 records
7 distinct products
12 products total
my desired result:
product1 2
product2 2
product3 2
product4 1
product5 2
product6 2
product7 1
total 12
I've used the split function to get the count of 12 products in another part of the report. I also have local variables for each of the 7 products.
In the crosstab row formula, I have if-then-else statements set up as follows:
if varproduct1=1 then "product1" else
if varproduct2=1 then "product2" else
if varproduct3=1 then "product3" else
if varproduct4=1 then "product4" else
if varproduct5=1 then "product5" else
if varproduct6=1 then "product6" else
if varproduct7=1 then "product7" else
"unknownproduct"
what I'm actually getting:
product1 2
product2
product3 1
product4
product5 1
product6
product7 1
unknownproduct 7
total 12
This is my problem. When Crystal finds product1 in the record, it then goes to the end. It doesn't CONTINUE reading the record to see if that record satisfies any of the other ifs. I know, that's how if-then-else statements work.
How can I get Crystal to read the record multiple times so that it will count all 12 of the products and put them in the correct line of the cross tab? I have a feeling an array is involved somewhere, but I don’t know exactly how. Can anyone help me?