The other day I discussed the solution for this problem in Report Builder / Reporting Services. A couple of days later I got the same question for Crystal Reports. Somebody wanted his report to look like this:
In the example I am showing Customers and Order numbers from the Noordenwind database, the Dutch equivalent to the Northwind database.
How can we get this result? I created a report grouped on Klanten.Bedrijf. In the group header I put the formula field orderreset:
shared stringvar ordercollect:="";
In the detail section I put the formula field ordercollect:
shared stringvar ordercollect;
ordercollect:=ordercollect & totext({Orders.Order-id},"00000") & ", ";
In the group footer I put first of all the group name field Klanten.Bedrijf and next to it the formula field orderprint:
shared stringvar ordercollect;
left(ordercollect,instrrev(ordercollect,",")-1)
Finally, I suppressed the details and the group header section ending up with the result on the picture.
Of course we could improve the formula fields in order to remove duplicates for instance. Then, we need three more complex formulas like
productreset:
shared stringvar array productcollect;
shared numbervar i:=0;
redim productcollect[1];
""
productcollect:
shared stringvar array productcollect;
shared numbervar i;
if not({Producten.Productnaam} in productcollect) then
(
i := i + 1;
redim preserve productcollect[i];
productcollect[i] := {Producten.Productnaam};
);
productcollect[i]
and productprint:
shared stringvar array productcollect;
join(productcollect,", ")
The result:
You can download the files klantenorders.rpt and klantenproducten.rpt through
https://drive.google.com/folderview?id=0B7HgkOwFZtdZVmhRQUZFM28yc1U&usp=sharing
In the example I am showing Customers and Order numbers from the Noordenwind database, the Dutch equivalent to the Northwind database.
How can we get this result? I created a report grouped on Klanten.Bedrijf. In the group header I put the formula field orderreset:
shared stringvar ordercollect:="";
In the detail section I put the formula field ordercollect:
shared stringvar ordercollect;
ordercollect:=ordercollect & totext({Orders.Order-id},"00000") & ", ";
In the group footer I put first of all the group name field Klanten.Bedrijf and next to it the formula field orderprint:
shared stringvar ordercollect;
left(ordercollect,instrrev(ordercollect,",")-1)
Finally, I suppressed the details and the group header section ending up with the result on the picture.
Of course we could improve the formula fields in order to remove duplicates for instance. Then, we need three more complex formulas like
productreset:
shared stringvar array productcollect;
shared numbervar i:=0;
redim productcollect[1];
""
productcollect:
shared stringvar array productcollect;
shared numbervar i;
if not({Producten.Productnaam} in productcollect) then
(
i := i + 1;
redim preserve productcollect[i];
productcollect[i] := {Producten.Productnaam};
);
productcollect[i]
shared stringvar array productcollect;
join(productcollect,", ")
The result:
You can download the files klantenorders.rpt and klantenproducten.rpt through
https://drive.google.com/folderview?id=0B7HgkOwFZtdZVmhRQUZFM28yc1U&usp=sharing
Reacties