woensdag 25 juni 2014

Crystal Reports: Group Chart Positioned Side By Side

Got a question from somebody. Charts showing products and revenues in a report grouped by category, can the different charts be shown two by two instead of one below the other?

I tried to find a solution on the internet but could not find an answer to this question. I finally succeeded to create this:


The example is based on the Northwind database, using the tables, Categories, Products, Orders and Oder_Details.

To get the charts side by side instead of one below the other, I used one sub report. Main report and sub report are based on the same data and contain the same charts.

I passed a shared variable from the main to the subreport:

shared numbervar group;
if groupnumber mod 2 = 1 then
    group:=groupnumber
ELSE
    group:=0;
group;

In the main report I used a formula to suppress the groups alternately:

groupnumber mod 2 = 0

In the sub reports I used the formula  to suppress the groups alternately:

groupnumber <> {@group}+1 OR {@group}=0

I linked the sub report like this:


You can download the file ChartSideBySide.rpt through

https://drive.google.com/folderview?id=0B7HgkOwFZtdZVmhRQUZFM28yc1U&usp=sharing
Een reactie posten