BIRT Report Tool - eclipse

I created a Report using BIRT Report Design in Eclipse Java EE IDE(Juno Release).
In that Report, For the single row it have multiple values for the corresponding one column(I used LISTAGG() oracle function to map that).
(i.e.) Result column have multiple values in the below database table output :
No Name Result Mark
-----------------------------------
1 John X 32
XX
XXX
2 Joe X 56
XX
XX
XXX
3 Andrew 34
XXX
XX
XXXX
…
It have both NULL and NOT NULL values in it.
"If the NULL values are in the middle means its showing the results properly in the Report"
Sample Result am getting in Report output for Joe (.pdf form)
No Name Result Mark
-----------------------------------
2 Joe X 56
XX
XX
XXX
Here the problem is,
“If First record has a NULL means it is not showing properly in the Report, instead of that NOT NULL value will print in the front and so on…”
Sample Result am getting in Report output for Andrew (.pdf form)
No Name Result Mark
-----------------------------------
3 Andrew XXX 34
XX
XXXX
But we have TWO NULL values present in the Front of Result column for Andrew (As you see sample oracle table output above)…
Is there any option to show blank in the first row(if it is a null) for the particular row in the birt report tool ?
Kindly Help me to Solve this issue… Thank you!

While I did not try to understand exactly what your issue is, in general when null values in the data are causing problems with a BIRT report. Use one of these two solutions.
Use the data base function to convert the NULL to something else. In SQL I use the command ISNULL
Use a computed column in the BIRT 'Data Set' to create a new column, write whatever you need in JS. In the example below I need to make a decision on a date field that is sometimes null, in comparison to an input parameter.
if (row["START_TIME"] == null){
"F"
} else if (row["END_TIME"] == null){
"T"
}else if (row["START_TIME"].getTime() >= params["WeekOf"].getTime() ){
"T"
}else if(row["END_TIME"].getTime() <= params["WeekOf"].getTime() ){
"F"
}else if(row["END_TIME"].getTime() >= params["WeekOf"].getTime() ){
"T"
}else{
"F"}

Related

how to change the date format in talend

I have two scenario's,which I couldn't able to solve.
PLZ help me.
Scenario 1:
I've two files Source_1_table(Excel file),Source_2_table(Excel File).
Attached screenshot
I want to compare the source_1 date to source_2 date.
If the source_1 date is matching with source_2 date then the status should be as "Y" if not match then the status should be "N".
Here I am trying with this code row1.date.equals(row2.date)?"Y":"N"
Note:both columns are string data type.
Scenario_2:
Here source_1 SAL column have a null value.and source SAL column have a VALUE.
While I am trying to compare the source_1 sal value with source_2 sal value getting null pointerException.
I am trying with this code relation.Is(source_2.sal)?" ":source_2.sal.equals(source_1.sal)?"Y":"N"
I want to replace a value with empty space or "empty" in null value.
Please look at this snapshot.
Scenario 1: “ row1.Date.equals(row2.Date)?"Y":"N"” is working if both Source 1 & Source 2 contain dates as string.
Scenario 2: To avoid the Null Pointer Exception, check for null values before comparing Source 1 and source data. Please try the expression below:
(row2.SAL == null || row2.SAL == ("")) ? "" : row1.SAL == row2.SAL ? "Y" :"N"

Crystal Reports 2016 Formula Syntax

I am new to Crystal Reports.
I have a DB where the Memory Column is being reported in KB.
I created a report for my IT director in which he wants that field to be reporting the memory in GB.
I tried this formula (based on book I purchased titled 'Beginner's Guide to Crystal Reports 2016')
IF {tblDts.Memory} = "" THEN "N/A" ELSE {tblDts.Memory}*0.4256
The error I get is
A number, or currency amount is required here
and it highlights the {tblDts.Memory} after my ELSE statement.
That field in the database only has numeric values (btw - 0.4256 is the decimal format for 10240, I tried a division statement with the same results so I figured I try a multiplication statement).
What am I doing wrong?
In a conditional statement both IF and ELSE should return same datatype else there will be these kind of errors reported.
Here for IF you are returning string and for ELSE you are returning Number hence the error.
Suggested would be return 0 in case of IF and your calculation in ELSE
IF {tblDts.Memory} = ""
THEN 0
ELSE {tblDts.Memory}*0.4256
Edit--------------------------------------------------
if IsNumber({tblDts.Memory})
then
(
ToNumber({tblDts.Memory})*0.4256
)
else
0

Crystal Report Cross Tab Calculated Member as text

I'vre created a cross tab report with 2 calculated Member to be able to have the difference between 2 column and the percentage of this difference in CR 2011. What I want to achieve is to create a new column that will display a test depending on the difference value.
Here is a example:
Col1 Col2 Difference Percentage Action
200 0 -200 100 DROPPED
100 100 0 0
0 300 300 100 ADDED
How can create this action column. Calculated member only want some amount value so I cannot output a text in the formula.
Thanks in advance for your help
I finally found the solution.
I can use the Display string formula in the Format Field properties (Common Tab). Here I just check the column and return the string I want otherwise I just format the number.
IF GetColumnGroupIndexOf(CurrentColumnIndex) = 1
AND CurrentColumnIndex =4 THEN
IF GridValueAt(CurrentRowIndex, CurrentColumnIndex,CurrentSummaryIndex) =2 THEN "DROPPED"
ELSE "ADDED"
ELSE
ToText( GridValueAt(CurrentRowIndex, CurrentColumnIndex,CurrentSummaryIndex),2,",")

Crystal Report - Conditional selection of record

I'm using Crystal Reports XI.
My data is coming from a dataset.
I have 2 tables which are related as follows:
Product(ProdID(PK), ProdName)
ProdPC(ProdPCID(PK), ProdID(FK), PCType, ProdCode)
The 'PCType' field determins the type of barcode format the 'ProdCode' represents. (E.g. EAN13, EAN8).
In crystal reports one 'Product' can have more than one kind of barcode which means my tables end up looking like this:
Product: ("1", "Example Product 1")
ProdPC: ("0", "1", "EAN8", "01234567"), ("1", "1", "EAN13", "012345678910")
In crystal reports I only want to print 1 barcode label for per product. However because they're are 2 records in the 'ProdPC' table, I will get 2 labels being printed for this 1 product.
What I want to do is place a condition in crystal reports which states, "If EAN13 is NULL then display EAN8, ELSE display EAN13"
I do not have access to the dataset and cannot prevent the application which calls Crystal Reports to create the barcode labels from sending more than 1 record for the 'ProdPC' table.
How can I create my conditional statement, purely in 'Crystal Reports 2008'?
What I have tried so far is:
IF {PartPC.PCType} = "EAN-13" AND {PartPC.ProdCode} <> "" THEN
{PartPC.ProdCode}
ELSE
/* DISPLAY PartPC.ProdCode containing EAN8 value */
;
But I am unsure how to then tell Crystal Reports to display the 'ProdCode' value where 'PCType' is equal to 'EAN8'
Group your report by Product ID.
Order your report by PC Type descending (within Product ID).
Include your report details in the Product ID footer (not the details section).
Option I: create two columns: one for each bar code. Do this in Crystal Reports.
Remove the PartPC table, replacing it with two SQL Expression fields:
// {%EAN-8}
(
SELECT ProdCode
FROM PartPC
WHERE ProdID=Product.ProdID
AND PCType='EAN-8'
)
// {%EAN-13}
(
SELECT ProdCode
FROM PartPC
WHERE ProdID=Product.ProdID
AND PCType='EAN-13'
)
Then create a formula field to display the appropriate one:
// {#barcode}
If Not(Isnull({%EAN-13})) Then
{%EAN-13}
Else
{%EAN-8}
Option II: alter the SQL to create to scalar-valued fields. Do this in your dataset or in a Command object (Crystal Reports).
SELECT Product.*,
(
SELECT ProdCode
FROM PartPC
WHERE ProdID=Product.ProdID
AND PCType='EAN-8'
) EAN_8,
(
SELECT ProdCode
FROM PartPC
WHERE ProdID=Product.ProdID
AND PCType='EAN-13'
) EAN_13
FROM Product
...

Can I report values from one field using another as a reference point in the same table?

My report returns a default of;
"My cat is Fat and Lazy"
Field_1 Field_2
======== ========
1 Sleek
2 Athletic
However I want to replace 'Fat' with 'Sleek' and 'Lazy' with 'Athletic'
So the final string will read ;
"My cat is Sleek and Athletic"
My question is this, can I make the report pick up (via a formula) that if Field_1 = 1 to replace Fat with 'Sleek'?
Field_1 is static but Field_2 is dynamic and the values will change on depending on the data.
Depending on how you're pulling the data you could do this in a couple of ways:
In the SQL add a CASE statement:
CASE WHEN field_1 = 1 THEN 'sleek' ELSE field_2 END AS modified_field_2
In a formula field (Crystal syntax used in example):
if { table_name.field_1 } = 1 then 'sleek' else { table_name.field_2 }
Edit:
Please see the following link for an example of how to join a table to itself (a self-join) in order to "link" the two records to get the full sentence: http://sqlfiddle.com/#!2/59566/16