Crystal Report with multiple datasources, one is empty - crystal-reports

I have a Crystal report with a table as a datasource and I want to include another table with details for the report footer.
I have two data sources in the report which are not linked, but when the selection criteria returns no rows from the main table, the results from the non-empty non-linked source are also empty.
I suspect it's doing a cross join between the two datasources, so if one is empty, that joined with another is also empty. The problem is I need my rows from the non-empty table to show in the report footer section, and they're getting suppressed by the other, empty datasource.
How can I get rows from an independent table to show in the report footer when the selection criteria and their parameter choices return an empty result set in the main table?
Thanks for your help,
-Beth
Also, I tried using a command as a datasource with sql like this:
select * from waitlist
union all
select distinct null as reportID, null as ..., lastupdated
from waitlist
but it still returns null for lastupdated and suppresses the subreport in the report footer.

I ended up setting my report datasource to a view which unioned another row to the table. I also needed to change my selection criteria so it allows this row to pass through.
Here's my datasource:
CREATE VIEW [dbo].[vw_rpt_waitlist] AS
select * from waitlist
union all
select distinct
reportID,
null as (fields...),
lastupdated,
'reserved' as countyName
from
waitlist
and here's my record selection formula:
({vw_rpt_waitlist.countyName} = {?County} or
{vw_rpt_waitlist.countyName} = "reserved") and
{vw_rpt_waitlist.reportID} = 14
I'm also suppressing the detail section if there were real rows returned:
formula = {vw_rpt_waitlist.countyName} = "reserved"
and to get the parameterized county name they selected in the page header of the report, I'm using:
dim t as string
dim c as string
if {vw_rpt_waitlist.countyName}="reserved" then
c = {?County}(1)
else
c = {vw_rpt_waitlist.countyName}
end if
t = "Waitlist by " + {#serviceTitle} + " and Waiver Need Index as of "
+ cstr({vw_rpt_waitlist.lastUpdated},"MM/dd/yyyy")
formula = t
Since the 'reserved' county always comes through, the subreports are not suppressed.

Related

an array's dimension must be an integer between 1 and 1000

Does anyone has any clue about the above error i get when I've tried to create sub report in crystal report?
Shared Stringvar array store;
store:= store + {table.A};
1
Try below, you are again selecting the values that are their in both tables but you need to select that are not in second table, I have updated the query
Select concat(REFNO_PFIX,'00',REFNO_SERL) as EventName,CROSS_REF from tizone1.baseevent where concat(REFNO_PFIX,'00',REFNO_SERL) not in ( SELECT baseevent.CROSS_REF from tizone1.baseevent as ta left join tizone1.baseevent as lta on ta.EventName = lta.CROSS_REF group by master_key );

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
...

Null when using Jasper report list component?

When select field and adding it to list component in jasper report it can't display values from database it return null
Query for it data set
SELECT TRAFFIC."DESC", INC.UNBILLED_AMOUNT FROM INC_CONTRACT_USAGE INC
INNER JOIN TRAFFIC_SERVICE TRAFFIC ON TRAFFIC.TRAFFIC_SERVICE_ID = INC.TRAFFIC_SERVICE_ID
WHERE INC.TRAFFIC_SERVICE_ID IN (1,2,3)

Crystal Report Parameter Array Index value

I have a Crystal Report with a formula on the page header like this:
dim t as string
t = "DD Waiver Waitlist "
if {rpt_xtab_waitlist.CountyName} = "statewide" then
t = t + {rpt_xtab_waitlist.CountyName}
else
t = t + "for " + {rpt_xtab_waitlist.CountyName} + " County"
end if
formula = t
The problem is not all counties have data for the report, but I still want the page header to contain the county name.
Ultimately, other staff puts a front-end on the report with a combo box for the parameter listing all of the counties, so the parameter UI will not come from Crystal. I can't just change the parameter to dynamic.
I thought I could use the county name from the parameter instead of the data, but that's in an array and I can't figure out how to index it.
I tried:
if {rpt_xtab_waitlist.CountyName} = "statewide" then
t = t + {?County}( RecordNumber)
else
t = t + "for " + {?County}( RecordNumber) + " County"
end if
but it doesn't print the county name corresponding to the selected county in the group tree.
How should I index a parameter array in a formula?
Thanks for any help,
-Beth
Sample county names:
Anoka
Hennepin
Yellow Medicine
Output I get now:
report with page header function suppressed when they select Yellow Medicine county as their parameter from the list of counties
Output I want to get:
report with page header function returning "DD Waiver Waitlist for Yellow Medicine County"
when Yellow Medicine county selection criteria applied returns 0 rows.
I don't think there is a useful index, and for our purposes, they can only select one county as a parameter, so I ended up using the (1) index of the parameter array.
If anyone knows of a way to derive a meaningful index, please post.

Dynamic grouping in crystal reports

So I have these 3 table/views in my database.
Table
id
template
View1 // the ids in this view have a corresponding id in table if template = 1
id
type1
View2 // the ids in this view have a corresponding id in table if template = 2
id
type2
So in my report, I want to select all the ids... and then group by template, and then group by type. I can do this for one View at a time by setting up the group to be either View1.type1 or View2.type2. But, I want it to group by View1.type1 if template is 1 and then I want it to group by View2.type2 if the template is 2.
So I made a forumla called type, and changed the group to that formula.. So I am first grouping by template, and then by type (my formula). If I set the formula for type as below:
formula = {View1.type1}
Then it works as expected and I see the correct grouping. It also works if I only do it for View2.type2.
However, when I do this:
if {Table.template} = 1
formula = {View1.type1}
else
formula = {View2.type2}
This returns no data for my grouping. Even if I do this:
if 1 = 1
formula = {View1.type1}
else
formula = {View2.type2}
This also returns no data. How is dynamic grouping supposed to work? I am missing something? I guess at the worst case I can make another view in my database or even use subreports... but I was hoping to have it work like this... I greatly appreciate the help guys!...
UPDATE:
So I can do formulas such as this one:
if {View1.type1} = "" then
formula = "[Undefined]"
else
formula = {View1.type1}
end if
It looks like I only have issues when I try to use a formula with the 2 views...