Group name field display data horizontally.

Posted on 2004-04-28
Last Modified: 2008-03-10

I have a group name field (GenericMiscPrompt.GroupPrompt) in Crystal 9 that generates characteristics for trucks and displays as

Drivetrain     FT Axle     10,000
                   RR Axle     19,800
                   Brakes       Hyd

Is there a way to have this field display the data horizontally?
Such as:
Drivetrain     FT Axle     10,000     RR Axle     19,8000     Brakes     Hyd

I believe in access this was done with cross tabbing.
Any help would be greatly appreciated. Thanks.

Question by:lburg55
  • 3
  • 3
LVL 100

Expert Comment

ID: 10941047
Are the details separate records?

You may be able to do this with a multiple column report.
Open the report
Select the Detail section
Click the LAYOUT tab
Setup the columns.
Ensure you select ACROSS then DOWN

Crystal does have cross tab reports and a wizard.  You might also try that.


Author Comment

ID: 10942002
Yes, the details are separate records.

Expert Comment

ID: 10962737
Are you wanting to report all Characteristics that are found for that Drivetrain, or specific ones that you know the characteristic type/id for (ftaxel, rtaxel, emptyweight, gross weight)?

If you want specific characteristics as columns, I've had best luck for performance and reusability by using SQL Expression. I created a oracle function that i pass the ID for the Truck and the Characteristic that i want to lookup, and i get back a single answer that can be dropped anywhere on the report, just like you are trying to do. You can do the same thing without the oracle function, by typing the sql in the SQL Expression.

If this will help you, i'll post the code samples .


Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.


Author Comment

ID: 10964902
Yes, please post a sample of the code. That would be a great help.


Expert Comment

ID: 10966527
I'm going to make 2 post. The first is a simple way doing the entire thing in Crystal Report. The second way is leveraging the power and reusability of oracle functions.

I have a Batch table which is a many table of Batches created by the business.


I have a Batch Characteristic setup table that defines 1000+ characteristics that can be used to record additional information about Batches


I have Batch Characteristic Detail which is records that actual Batch Characteristic results for a Batch



In Crystal Reports create 2 SQL Expression. One for each column that i want.

Select max(characteristicvalue)
from batchcharacteristicdetail
where batchid = "BATCH"."BATCHID" and
Batchcharacteristicid= 44001

The Max() is required because you will get error if more than 1 row is returned.

Select max(characteristicvalue)
from batchcharacteristicdetail
where batchid = "BATCH"."BATCHID" and
Batchcharacteristicid in (44004, 44354)

This one for Volume allows you to look up 1 or more Characteristic ID.

Accepted Solution

sortascend earned 125 total points
ID: 10966658
1. But what if you want to do something like return the most recently updated Characteristic for the Batch from a list of possible Characteristic IDs. This feature is crucial since sometimes the information is recorded using different ID depending on the situation. The report needs to find the info no matter which ID is use and determine which result to show if more than one is found. (You could modify code below to concatenate all results found into a single varchar variable to return from Oracle to Crystal).
The TableofNumbers solves issue of being able to pass only 1 number as a parameter to function. The fnBatchChar() function adds more complex logic than the SQL Expression from the Crystal example i just posted.

2. And you want to reuse the code, since this is task is required frequently.

This solution and methodology came about as result of over 2 week of trying to come up with a reusable solution taking into account Crystal Reports limitations. I talked to a number of expert Oracle Developers but they were not use to thinking around the constraints generated by Crystal. I tried methods of using outerjoins and the (+)= oracle operator. But this required hardcoded views and i think it had problems if looking for more than 1 Char ID. I took some of the things i learned from them to develop this unique design.

I hope this works for you and that some other people might benefit from this. I should probably type up a simple explanation of the problem and design.

SQL Expression
Note: when you add a Crystal Report field to a SQL Expression it puts "" around the table and field like this "table"."field".

fnBatchChar("BATCH"."BATCHID", 44001)

This is more robust version of %Size from my last post.

fnBatchChar("BATCH"."BATCHID", '44008, 44354')

This is more robust version of %Volume from my last post.

Oracle Code
--Declare type TableofNumbers
create or replace type TableofNumbers as table of number;

--Convert a list of numbers receieved as a varchar array
--to a table of numbers. This is used by fnBatchChar below
--since you can't check for string of numbers using the IN clause
--without going through TableofNumbers function.
--Example: str2tbl('1,2,3')
--          Return
--               1
--               2
--               3
create or replace function str2tbl( p_str in varchar2 )
         return TableofNumbers
      l_str   long default p_str || ',';
      l_n        number;
      l_data    TableofNumbers := TableofNumbers();
                  l_n := instr( l_str, ',' );
                  exit when (nvl(l_n,0) = 0);
                  l_data( l_data.count ) := ltrim(rtrim(substr(l_str,1,l_n-1)));
                  l_str := substr( l_str, l_n+1 );
            end loop;
            return l_data;

--Find the Result of the most recently updated Batch Characteristic
--for a Batch from a list of Characteristic ID (number) to look for.
--Input list of Characteristic IDs as a string of numbers.
--Example: fnBatchChar(56845, 11) or fnBatchChar(56845, '11, 14, 54')
--The String of CharId is used because related information may go by
--different CharID depending on the type of Batch. This method will still
--allow for creating a single column for all batches included in the
--primary query.

CREATE OR REPLACE function fnBatchChar
      (fBatchID in number, fBatchCharIDs in varchar)
return varchar2
vCharValue varchar2 (60);

      --Use Max() to return the most recently updated Characteristic from the list
      --of Characteristics types that are being searched for.
      select max(characteristicvalue)
      into vCharValue
      from (select characteristicvalue from BatchcharacteristicDetail
            where batchid = fbatchid and batchcharacteristicid in
                  ( select * from THE ( select cast(str2tbl(fBatchCharIDs) as TableofNumbers )
                              from dual )  )
            order by changeddate desc
      where rownum <= 1;

      return vCharValue;
create public  SYNONYM fnBatchChar FOR fnBatchChar;
GRANT execute ON fnBatchChar  TO HPREAD, HPAPP;

Author Comment

ID: 10981086
Thanks! This has been a big help.


Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question