How to change ordering on multiple columns in Crystal Reports - crystal-reports

I am trying to display a list of names in crystal reports in multiple columns only if there are enough names that it would split into multiple pages otherwise. I want the ordering to be "across then down" when it's in two columns, otherwise if there aren't enough names, just display a single column of names in order.
The problem I'm having is that the ordering is off when it's in two columns, it goes like:
A - F
B - G
C
D
E
But I want it to be like:
A - B
C - D
E
F
G
And for only a small group that fits on one page, like this:
A
B
C
I have "Format with Multiple Columns" in the "Common" tab, and "Down and then Across" on the Layout tab.

Crystal doesn't have dynamic expression option for 'Printing direction' so you must commit to either 'Across then Down' or 'Down than Across'.
As a way around that, you can insert to subreports, each with a different choice for that property. Then, suppress one and show the other based on the number of records.

Related

Crystal Report - two detail sections each showing their own subset of data

Is it possible to have a Crystal Report with two detail sections with each showing a subset of the results returned from the SP that the report is linked to?
For example in DetailA I want the records where FieldA in (a,b,c) and in DetailB I want records where FieldA in (d,e,f)
I know there is the Select Expert that can be used but that seems to work across the whole report rather than each individual detail section
It would be nice if I didn't need to create formulas as there are about 20 fields in the detail sections. Is there some kind of master formula that can be applied to the detail section as a whole?
You can do this pretty simply by just setting up your two Details sections the way that you want and placing all of the records' fields you want to display in each. Then, add a suppression formula to each of the Details sections. You can access the suppression formulas of each section by right-clicking that section, choosing 'Section Expert', and then clicking the formula button next to 'Suppress (No Drill-Down)'
Detail Section A: not({table.fieldA} in ['a','b','c'])
Detail Section B: not({table.fieldA} in ['d','e','f'])
Now, your Details A section will only display when the record is of type a, b, or c and your Details B section will only display when the record is of type d, e, or f.
While Ryan's method will work, it is a good idea to add to it and group by a formula field:
if {table.fieldA} In ['a','b','c'] then
'Group 1'
else
'Group 2'#
Then add the suppression formula for details A & B as:
{#MyGroup} = 'Group 2' and {#MyGroup} = 'Group 1'
This provides three benefits:
It will automatically sort the two sections into Group 1 and Group 2
It will only ever show one or the other, and always show one, Ryan's method could hide unexpected details which can cause problems
It is much easier to maintain as you're not keeping different lists in different sections

Crystal Reports 7 CrossTab Suppress Column

I'm trying to modify a report created in Crystal Reports 7 (which I know almost nothing about). I want to use a CrossTab, as this seems to be the best way to accomplish what I want. I have a column with three possible values: A, B, C. The cross tab creates three columns. I want to suppress C. How can I do this?
Also, is there anyway to create rows based on one field (i.e. a PK value), but display another - like a description? For example, if a list of states have a PK value of 1-50, I want them ordered by PK, but I want to display the state name.
All you ask is possible;
i suggest not to use cross tab: cross tab is intended for an uknown number of rows and columns (varying on data) ad for summarizing (max value, sum of values) results on a grid.
you should, instead:
Create a blank report
Drop the fields from the Field explrorer into the Details Section (just A and B columns)
Use Report Sort Expert to sort elements no the PK value

Hide a column in cross-tab depending on the value of parameter (Crystal Reports XI)

I'm using Crystal Reports XI (R2) and have a cross-tab which displays information about flights. There is the 'Total' column' as well as the Arrivals and Departures columns which are created automatically thanks to the grouping condition. What I'm trying to do is to have the 'flight directions' parameter, where the user can select 'All, departures only or arrivals only' values and according to this selection the cross-tab would have one or two columns. How can this be achieved? I tried using the following formula(and have the suppress empty columns option enabled) :
if {?Pm-#flight_direction_description} = "Departures Only"
then
if ({Command_1.IsArrival} = 1)
then 0
else {Command_1.IsArrival}
which indeed works (only one column is displayed) but then under the Departures column it lists all the flights (so the departures column is the same as the Total column) whereas it should only display information about departing flights.
I've had similar situations come up; while certainly not ideal, and if no one has any better suggestions, you could create Detail A, Detail B and Detail C sections, all of them suppressed. From there...
You could put your "All" crosstab in Detail A
Create a second crosstab for Destinations only, and put that in Detail B
Create a third crosstab for Arrivals only, and put that in Detail C
Then, in your Detail A, B and C sections, you can condtionally unsuppress the section you want based on the parameter passed in.

Multiple Groups in jasper reports

I want to create multiple groups in ireport, and the data should display in a group-wise manner.For Eg:
First the Group1 data should be printed completely, then,
Group1:
Module Data
After this i want to print the Group2 data completely
Group2:
Category data
I am using the Result Set datasource.
Can Someone help me in this?
Jasper reports will work exactly in this manner as long as your query results are ordered properly.
For example, let's say you are grouping by a field called "MY_GROUP" and it has values "GROUP A" and "GROUP B". In your report you will create a group for field "MY_GROUP". In your query, make sure you have MY_GROUP as the first field in your ORDER BY clause. You can also accomplish this in iReports by adding the "MY_GROUP" field as your the first field in the Sort Options section of the Report query.
Now that you have added your group and are ordering properly your results will come out like this:
Header - GROUP A
Detail - GROUP A
Footer - GROUP A
Header - GROUP B
Detail - GROUP B
Footer - GROUP B
Exactly as you wish. My guess is that you were not properly ordering your query results. This could result in having multiple groupings for GROUP A, GROUP B, etc. all interspersed.
If groups in iReport don't keep all the data together, use subreports. When Jasper gets to a subreport, it runs the whole subreport and puts the whole thing into the report. You could have something like:
Subreport 1 - Group 1
Group 1 first record
Group 1 second record
Group 1 third record
...
Group 1 last record
Subreport 2 - Group 2
Group 2 first record
Group 2 second record
Group 2 third record
...
Group 2 third record
It's exactly as Tom said. Jasper Reports Groups do not order the data retrieved from the query, they just take it in the order it comes.
In order to display the information in a group-wise manner, you have to add an ORDER BY to the query so the rows the report receives are already ordered.
So there is an issue that happens when you use multiple group headers. The first header behaves like expected ordered by Column Value A only on unique values. The 2nd header using Column Value B will print on every row despite being non-unique values.
In theory you should be able to use ORDER BY:
ORDER BY ValueA, ValueB
to properly display the report assuming you are using sql, plsql, etc... However, in my case that did not happen, though for others it seems to work.
Use subreports to attach the minor differences via unique reports. You create a root report with empty details. Then you create Unique reports to serve as sub reprots. Finally, you use the subreport element to link the values into the root report. Though that is a good bit of work and may cause repeat code.
A hacky way I used was: A mixture of "Print When Expressions" with logical boolean expressions with 2 group headers and a column header.
Boolean Expressions:
$F{QUERY}.equals(Query1) && ($P{P_Typequery}.equalsIgnoreCase("QueryA") && $P{P_parameter} == null)
and
$F{QUERY}.equals(Query1) && ($P{P_Typequery}.equalsIgnoreCase("P_QueryA") && $P{P_parameter} != null)
with two group headers and a column header. The column header will not repeat for every row so you assign one of the booleans expressions to it's "print when" so it does not always print. The first group header will not repeat for every row and works. The 2nd group header is used for the times you DO want it to repeat for every unique value since it always prints for every row, and you use the other boolean on it's "print when". Hope it helps

CR2008: display cross-tab with no spanning

I'm writing a report that can be exported to excel and using cross tabs. I have two groups A and B, where A can contain multiple subgroups of B.
When I drag A and B into the rows on the left, the outermost group A spans multiple rows depending on how many subgroups of B there are.
Is there a way to have group A repeat itself for every row of B? Like a full table without any of that cell-spanning.
I'm not sure if this will work for you since it means you can't do Totals on the outer group, but here is one possible solution. Create one formula that concatenates both group A and group B values together and use that in your cross tab instead. In this example, I had to use a format string to get the numerical-to-string values to sort correctly.
EDIT: Never mind, I fixed it so you can have the outer group Totals, too. Just leave the outer grouping the way it was, but replace the inner grouping with your new concatenated string (via the formula you just made). You'll have to suppress the outer group header (shown in the screenshot) and format the grid lines to look nicer or overlay a whiteout box, though (not shown in screenshot).