Chris
Chris

Reputation: 1475

Crystal Report with dynamic Rows and Columns

I need to write a crystal report that uses data which has both dynamic rows (which is normal) and dynamic columns.

As I understand it, a cross tab will allow me to have dynamic columns but not dynamic columns and rows. How can I drag a column to a report when those columns are dynamic?

I know how to create the SQL query that provides the data and inserts columns in dynamically, the question now is how to present it.

If anyone has done something similar or can give me some pointers, I'd be very grateful.

Many thanks,

Chris.

Upvotes: 2

Views: 2345

Answers (1)

Ankit
Ankit

Reputation: 690

Have a look in following Stored Procedure

CREATE PROCEDURE MY_PROCEDURE
@P_QNO INT
AS
BEGIN
IF @P_QNO=1
SELECT FIELD1 AS F1, FIELD2 AS F2,0 AS F3 FROM MYTABLE1
ELSE
SELECT FIELD3 AS F1, FIELD4 AS F2, FIELD5 AS F3 FROM MYTABLE2
END

This procedure will always give you 3 Columns F1,F2,F3 you can easily use them in Crystal Reports. Make sure that every Query returns same number of columns and have same name that will do the Trick. I am using it.

Upvotes: 1

Related Questions