I have look through the links below:
Dynamically changing columns in Crystal Report 2008
Dynamic Columns in Crystal reports
However, it seems not suit my requirement.
So, basically, i have database fields that contains the following:
type_id | type_value
1 Test1
2 Test2
So, I would like to have the crystal report generate the columns as
Test1 | Test2
1 2
If I have changed the data as below:
type_id | type_value
1 Test11
2 Test22
The crystal report columns would react automatically:
Test11 | Test22
1 2
Any idea on how to achieve that?
Thank you!
I would have the pivot be done in the data source instead of Crystal Report.
Prepare the data table from dynamic SQL / application code doing pivot. Know the max. column you can show in the report. The output of the table like this
Column1Name, Column1Value, Column2Name, Column2Value...
Have your report column suppress by column name if it is null.
use cross tab in crystal report for that purpose.
In rows put type ID and column put type value.
Related
Summary
We have a Crystal Report referencing a single Oracle view. There are no other tables or joins in the report. The view is composed of several selects, joins, and other data transformations (e.g., sum, case, to_date, group by).
Four columns from the view display as blank (null) in the report. These same columns display correctly in Oracle SQL Developer and via a select using the Oracle Data Provider for .NET in a C# application. All other columns display correctly in the report.
In addition the Browse Field option displays no values for the affected fields, but does display options for unaffected fields of the same type. Similarly, if I make an affected field a parameter of the report no options are presented.
We verified that in all cases we are connecting as the same read only user in Crystal Reports, Oracle SQL Developer, and in our Web Application.
Failed Resolution Attempts
We removed and replaced the view and fields in the Crystal Report.
We created a brand new report connecting to the same view.
We created a new view (from the same SQL) to be used in the same report
We verified database via Crystal Reports
We converted implicit date conversion from
score_month = '01-SEP-2017'
to
score_month = TO_DATE('01-SEP-2017', 'dd-MON-yyyy')`
per https://stackoverflow.com/a/37729175/19977
Other Oddities
Exporting the data from the view to a table works, but we want to use a view
We're at a loss as to what the cause of this issue is. Any ideas?
Several edits to the view were required to resolve this issue.
We removed Oracle specific sql per https://stackoverflow.com/a/37729175/19977. Example:
-- replace
TRUNC(sysdate, 'MONTH') AS score_month`
-- with
TO_DATE('01-SEP-2017', 'dd-MON-yyyy')
-- and replace
where score_month = '01-SEP-2017'
-- with
where score_month = TO_DATE('01-SEP-2017', 'dd-MON-yyyy')
Fully qualify all tables and views used in the Oracle view with the schema and table name. Example:
-- replace
FROM table t
-- with
FROM our_schema.table t
It remains unclear why the view would work as intended from Oracle SQL Developer and in application via the Oracle Data Provider for .NET but not from Crystal Reports. Further insight into this issue is welcome.
I use Crystal report 2011 to create report from with data from Oracle database. I have a Allow multi values parameter name userid (userid is string).
I want to query
Select ... from table where userid in {?userid};
I try {?userid}, ({?userid}), '{?userid}' ... but it's not working.
what should I do?
Put the cursor on the place where you want it, and double click on the parameter.
ALTER TABLE Warranty ADD COLUMN StartDate2 DATETIME, EndDate2 DATETIME, Status2 BIT
This isnt getting me far - I even tried to break it down like this:
ALTER TABLE Warranty ADD COLUMN StartDate2 DATETIME
But get an error saying
"The following errors were encountered while parsing the contents of the SQL pane: ALTER TABLE Warranty ADD COLUMN StartDate2 DATETIME. The query cannot be represented graphically in the Diagram and Criteria Pane.
I should note that I did try to add the columns in MSAccess itself but my Visual Studio's didnt update after a refresh. Any ideas?
In Access you can do:
Currentdb.Execute ("ALTER TABLE Warranty ADD COLUMN StartDate2 DATETIME")
So call the same command from VS if that is what you want.
I'm new to Birt, so I might be doing this the wrong way...
What I need to do is to display some statistical data in reports.
Data will be prepared overnight in some special tables (I wanted to use materialized views, but haven't been able to find it in Birt report designer when connecting through JDBC to my DB - so I'll be using tables instead).
The typical chart I need to draw is :
- month on X-Axis
- a value on Y Axis.
For the Y Axis, there will be multiple series... But I don't know how many. Each serie data will be fetched from one of those special report table I was talking just above.
I have two main problems :
- how to display N series on a chart, N being unknown ?
- how to dynamize table names in a data set ?
Is there a more Birt-ish way to do so ? Maybe I have it completely wrong from the beginning, really don't know.
Thank you for your help.
Databases don't allow to dynamize table names with a regular query parameter, so we need to handle this by script.
The cleanest way would be to do this with a DB stored procedure: the BIRT dataset query just invokes a stored procedure of your DB with the table name as parameter. Here is an example of a such dataset query with MySql JDBC:
CALL `myschemaname`.`mystoredprocedure`(?);
Here, the question mark '?' is a query parameter, in the dataset editor we link it to a report parameter representing the table name. Then this stored procedure builds a dynamic query and returns relevant data.
Another option is to inject the table name in "beforeOpen" script of the BIRT dataset:
1- In your dataset, initialize the query with an arbitrary valid table name, for example:
select *
from myvalidtablename
2- In Eclipse designer select your dataset -> Script tab -> beforeOpen
Assuming the table name is in a report parameter:
this.queryText=this.queryText.replace("myvalidtablename",params["myTableNameParam"].value);
Concerning how to handle N series, it depends on how datarows are designed in tables. Two main cases:
Case 1 - Series are in multiple rows such:
month1;serie1;value
month1;serie2;value
month2;serie1;value
month2;serie2;value
This is the smartest case because it is dynamically handled in a BIRT chart with "Option Y series grouping". This is how this chart works: country field is set as optional grouping and BIRT handles everything.
Case 2 - Series are in multiple columns:
month1;valueSerie1;valueSerie2
month2;valueSerie1;valueSerie2
In this case we need to declare each serie explicitely. In the chart editor, by dropping down "Value (Y) series" menu we can create as many series as we like.
Currently I'm using Birt Report to generate report from my system. I'm using input parameter to send parameter from my system to Birt Report. The problem is when I'm trying to send multiple parameter from my system.
SQL statement at Birt Report for one parameter
select actualdate from table1 where storeloc = ?;
When I use this query for one parameter, it work.
I tried sql like this
select actualdate from table1 where storeloc = params["storeloc"].value;
I already created parameter at data set and report parameter but it's still can't gets to work
and also birt dont show me the options in edit dataset for query and Linked To Report Parameters in parameters
so what should i do?
Create a parameter storeloc in report params section of Data source.
Write this query in dataset open:
select actualdate from table1 where storeloc='"+params["storeloc"]+"';
Fetch the actualdate value in data source fetch and run the report.