I am unable to dynamically change the column header values during run time while creating a jasper report. Why do I keep getting string to boolean cast exception everytime I assign the value to table element's column header??
I have a column header that is a part of the table element. And this table and its dataset are not a part of the main data set. I want to the column header to change dynamically based on values in the main dataset. The main dataset and sub data set return different resultsets
The steps I followed were:
create a variable called v1_enabed (string) and v1_display(string) in the main dataset. I also assigned the required fields(from the main data set) to these variables
I created a parameter p1(string) in subdataset
I use the subdataset fields for table creation. I used the table element.
I go the table and map the parameter p1(string) to the table. And I assign the expression ($V{v1_enabled} == Character.toString('1')) ? $V{v1_display} : $V{v1_display} to it
Until here whenever I run the report, I do not get any error.
Now, I go the table. Pick up the 5th column and assign this in the print when expression section -- $P(p1)
Now, comes the error: java.lang.String cannot be cast to java.lang.Boolean
How do I solve this?
Related
I am currently using Azure Datafactory in that I am creating a Derived column and since the field will always will be blank, so I want the value to be NULL
currently Derived Column I am doing this for adding the expression e.g. toString("null") and toString(null()) but this is appearing as string. I only want null to appear without quotes in Json document
I have reproduced the above and got below results.
I tried to give null() to a column and it gave the error like below.
So, in ADF Dataflow, there should be any wrap over null() with the functions like toInteger() or toString()
When I give toString(null()) when id is 4 in derived column of dataflow and the sink is a JSON, it gave me the below output.
You can see the row with id==4 skipped the null valued key in JSON. If you give toString(null()) same key in every row will be skipped.
You can go through this link by #ShaikMaheer-MSFT to understand more about this.
AFAIK, The workaround for this can be to store the null as 'null' string to get that key in JSON like this and later use this as per your requirement.
I want to reference my MAIN dataset in a Jasper .jrxml when querying for my subdatasets.
I have about a dozen sub-datasets that all rely on the main set, in the following way:
SELECT
what_i_need,
for_my,
subdataset
FROM
(my main dataset which has a fairly long query) m
group by m.sth
order by 3,4 desc, 2;
What that does is query the main and then use that as a table to query for the subs, but the drawback is that I have to change every subdataset manually every time I need to change the main
I'm aware that I COULD go for creating a view in the database and then simply referencing that from inside Jasper for both main and subs.
(And also changing the view definition as needed)
I'm asking whether Jasper can be "taught" how to use the entire main dataset as a parameter for the subdatasets?
The goal is to set all the subdatasets once with some sort of parameter, and only change the main, and have the expected results.
The end goal should be something like this:
SELECT
what_i_need,
for_my,
subdataset
FROM
$P{Main_Dataset} m
group by m.sth
order by 3,4 desc, 2;
Add String parameter to your dataset, let's say pQuery.
SELECT ...
FROM ( $P!{pQuery} ) m
GROUP BY ...
ORDER BY ...
Exclamation ! char is important.
In chart's datasource:
Use connection expression with default value $P{REPORT_CONNECTION}.
Add pQuery parameter and set expression as $P{JASPER_REPORT}.getQuery().getText()
I have a cross tab element in my layout. One of the values in the column group is null and I don't want to display that column with null value in the output.
I have tried the checking the blank when null value and modifying print when expression property. But all it does is replacing the null value with blank but the column still comes in the output.
Current output
Expected output
To change the name in column header from null to something else you can modify the bucketExpression
<bucketExpression><![CDATA[($F{myField==null}?"New name":$F{myField})]]></bucketExpression>
Using this you can also move the values into a new bucket (column).
If you like to remove the whole column, AFIK there is no other method then to filter away the null values in your datasource before you pass it to the crosstab.
The options are:
If you are using an sql datasource just add the field in the where clause, for mysql that would be something like WHERE myField is not null
Use a filterExpression on your datasource eg.
<filterExpression><![CDATA[($F{myField}!=null)]]></filterExpression>
Develop a custom JRDatasource wrapping the datasource that ignores and jump if record has null value.
Conclusion: To remove the column, you need to remove the records from datasource before you pass it to crosstab.
I have a dataset referencing a proc. That proc takes in a #UserName
In my parameters of my dataset, I have specified a new param called #UserName and for its default value the expression =User!UserID but I still get this error when the report tires to render:
The default value expression for the query parameter #UserName contains an error [BC30654] 'Return' statement in a function, Get, or Operator must return a value
The only thing I can think of is that instead of modifying the existing datasource I had defined in the report, I removed and added a new datasource. I hope that doesn't matter as long as there is a valid data source for the report to go on that has those fields...I just switched this report to reference a copy of our current database for testing purposes.
Sounds like the report parameter is not being passed to the stored procedure.
In the Dataset Properties, click on the Parameters tab and check that the stored proc parameter #Username is correctly mapped to the Report parameter #Username.
I've got a chart that uses a secondary dataset. It allows for the use of the fields and parameters of the second dataset, however I'm not able to use the parameters set in the main report dataset. Does anyone have any clue how to access the values of the parameters?
For example
I have the following parameters in the main dataset:
valueOne
valueTwo
And a secondary data set:
fieldOne, fieldTwo
From the chart that is set to use the second dataset, how would I request parameter: "valueOne"?
Add a parameter to your subDataset that has the exact same name as the parameter in the main dataset. Leave the default value expression blank and do not prompt for a value. When you reference the parameter in the subdataset, the value from the main dataset will be returned.
So in your case monksy, you should add an empty parameter named "valueOne" to your second dataset.
I've never seen this behaviour documented anywhere; I found it out by accident when working on a report.