Crystal reports - get crosstab column value from different table - crystal-reports

I have a crystal report based on xml data with a crosstab for displaying the main set of data that I want.
Some of the values that I need to display in the header are in a dictionary 'table' in the xml and I need to extract the value of a field where the name is e.g. 'CrossTabColumnName'.
I can do this in a subreport and use a shared variable to put it onto the main report, but it won't let me put it in the crosstab because it 'has to be evaluated later' - fine I get the idea behind this but how can I get this value into where I want it?
I just want to be able to say, for example: Select Value From DictionaryTable Where Name='CrossTabColumnName', and put that into a field I can use in the cross tab.

Related

jasper report show count on footer of a specific query

am very new to jasper report
also I have tried looking at videos but can not seem to get this one concept
basically there is this main query which i have
select * from table
which is populated in the details area
however i want a second query
select count(*) from table where name = "tim"
and put the count on the footer
can this be done using jasper
any tutorial to this concept or guidance would be helpful
to sum up the details area should show all the data where as the footer should only show counts of a few things.
You can only have one DataSet (therefore query) for the report. In your case this is your main report select * from table, which seems to be working well.
You have two options for adding the information you want:
(and I would say the better option) is to add a variable $V{tim_count} which is configured as:
initial value 0
expression value "tim".equals($F{name}) ? 1 : 0"
calculation function sum
there are multiple ways to increment this variable, so I'll leave that with you. In the footer you would then add a text field with the $V{tim_count} variable as it's contents.
You can read about variables here https://community.jaspersoft.com/wiki/variables
You can add an object that has it's own DataSet:
Table
List
Subreport
You would then be able to add your query to that object and display it appropriately. As you can see, displaying a COUNT is not really the most appropriate way to do this.
Note - I don't suggest this way

Passing values from main report to subreport in JasperReports

I have a simple select sql query with 2 parameters that I want it to be in my query text in main report. It returns about 100 values that I want to put in 10 subreports (10 values per subreport). On main report I need to display only one parameter. All the values from query I need to be in subreports. How do I pass them?
Connection to database is returned to me from application, parameter values also. I'm using iReport 4.7.0.
Parameters are attached to the dataset, if you expand the dataset itself, you'll find a section there for parameters, just like in your main report.
You'll need to link the parameters together though, using the connection properties where you're actually using the dataset, eg, in a chart or a table. For example, in the table, you go to the dataset tab of the properties pane, and click on the parameters button to map the parameters between your main report and your sub dataset.
More here.

SSRS no data in report

I have a single tablix on the SSRS report which fetches data from a stored procedure.
I am trying to show a meesage to the User when no data is present say, "** There is no data for this report*". I can do this easily by specifying this message in the **NoRowsMessage property of the tablix. But I want to show the headers of the tablix along with this message.
If I don't set the NoRowsMessage property, I get the headers but no message, but if I do, I get the message but no headers.
I need some help with this.
Note: I am using SSRS 2008.
Edit:
I can also put up a textbox with the relevant text message below the tablix and set it visible only if the tablix contains no rows. But I am not able to figure out as to how do I find out from the Visibility expression of the textbox whether the tablix contains any rows or not.
A tablix object is related to the underlying dataset, so if there's no data, there's no table in the output.
Other than using the NowRowsMessage property, the only other way I can think of to enforce this would be to ensure your query returns an empty value placeholder when there are now rows returned. This way you would have, in essence, a single data row.
You could then try and add a conditional expression on the table (i.e. on the Visibility property of the details row) to prevent any rows containing your placeholder from showing up.
So in your query you could have:
IF (##ROWCOUNT= 0)
BEGIN
SELECT
'[IAMEMPTY]' as [Col1]
,'[IAMEMPTY]' as [Col2]
,'[IAMEMPTY]' as [Col3]
END
And then in the Visibility property of your table's detail row:
=Iif(Fields!Col1.Value = "[IAMEMPTY]",True,False)
EDIT: Alternatively, to check if the DataSet is empty in SSRS and show a rectangle containing your message/headers (as mentioned in TooSik's comment), you could set up a rectangle with this in the Visibility expression:
=Iif(Rownumber("Dataset_Name")=0, False,True)

Iterate through data table in Crystal Report

How can i create function to iterate through datatable to read value from table
e.g
Function GetVal(integer id)
//iterate here and match value from table using id
return value;
and call this function on report field
i am using crystal report 11
any clues??
Option 1: Make your function (or equivalent SQL query) outside of Crystal and link to it like any other source. The practicality of this option depends on the details of your report.
Option 2: Crystal doesn't have a built-in Get() function that I can find. So, you'll have to get creative with subreports. For example, let say's say you want to get {TargetFld} from {LookupTable} based on {CriteriaFld}:
Make a subreport. Use {LookupTable} for your data source.
When entering subreport links, choose {CriteriaFld}.
In your subreport, make a formula. Use it to create a Shared variable and set the value to whatever value you want to pass back to the main report.
Position the subreport 1 section above the section where you need to use this value. (Otherwise it won't evaluate when you expect it to).
Create the Shared variable in the main report.
Use it as normal.
If you're not familiar with subreports or shared variables, I suggest first looking them up in the Crystal help files (F11). This will make alot more sense that way.

Can I assign a value for one parameter

I am using crystal reports 2008. I want to generate a report for which i will get one value from one subreport and i want to pass this value as a parameter so that i can include this value in the sql command.
For eg.
From my subreport i will get customerkey and i want to pass this value in the sql as
{?customerkey}
Sql is 'select card_number from customers where customerkey={?customerkey}'
For this i created parameter in the command and added like this.
But what my problem is this customerkey is getting from subreport(using shared variable).If i get a value customer_key from subreport how will i assign this value to {?customerkey}. I tried like assighning this value but i dont want to popup {?customerkey}this value as a parameter.
Can anyone help? Please
So you want the data shown in the main report to be based on a parameter passed to it from a subreport? I don't think this is possible - the Report Processing Model (described here) states that SubReports are in 'Pass 2', while data retrieval is in 'Pass 1'. This means that the parameter prompt will always appear first.
You might instead be able to have the main report contain TWO subreports, the first of which is used to retrieve the parameter and the second uses it. That can get very messy, especially when dealing with page headers and footers.