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.
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 am using an expression builder in derived column action of Azure data factory. I have an iif statement that that adds objects to a single array of objects based on whether 5 columns are null. Within the iif statement if the object is not null it adds it to the array object and I did not specify an action for when the columns is null. So if the 3 columns have a value then there should be 3 total objects in the array but the issue is for those 2 empty columns they show up as 2 "null" values within the array. I don't want that. I just want to cleanly have only the 3 objects in the array. How can I convert the null values to whitespace or is there a better way to get this done?
I've made a test to conver null value to whitespace successfully.
My source data is a csv file with 6 columns and some columns may contains Null value:
In the dataflow, I'm using Derived Column to convert the Null value.
In the data preview, we can see the Null value was replaced with whitespace/blank
Summary:
So we can use expression iif(isNull(<Column_Name>),'\n',<Column_Name>) to replace the NULL value to a whitespace.
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?
When i have the follow query:
str(db(db.items.id==int(row)).select(db.items.imageName)) + "\n"
The output includes the field name:
items.imageName
homegear\homegear.jpg
How do i remove it so that field name will not be included and just the selected imagename.
i tried referencing it like a list [1] gives me an out of range error and [0] i end up with:
<Row {'imageName': 'homegear\\homegear.jpg'}>
The above is not a list, what object is that and how can i reference on it?
Thanks!
John
db(db.items.id==int(row)).select(db.items.imageName) returns a Rows object, and its __str__ method converts it to CSV output, which is what you are seeing.
A Rows object contains Row objects, and a Row object contains field values. To access an individual field value, you must first index the Rows object to extract the Row, and then get the individual field value as an attribute of the Row. So, in this case, it would be:
db(db.items.id==int(row)).select(db.items.imageName)[0].imageName
or:
db(db.items.id==int(row)).select(db.items.imageName).first().imageName
The advantage of rows.first() over rows[0] is that the former returns None in case there are no rows, whereas the latter will generate an exception (this doesn't help in the above case, because the subsequent attempt to access the .imageName attribute would raise an exception in either case if there were no rows).
Note, even when the select returns just a single row with a single field, you still have to explicitly extract the row and the field value as above.
I my web application I am using I-REPORT designer for designing report.
For the data used in report,I have written a query that fetch two column values from different table.Here data type of column data is real.In ireport corresponding data type is Float.
Here,if one of the data have a value,other have a no value or empty.So I have to display a value that is not null or empty using text field,when the report is generated.So I have implemented condition in text field
( $F{permit_quantity}==null ?$F{fst_insp_qpqlml_quantity} : $F{permit_quantity} )
Here the fields $F{permit_quantity}, $F{fst_insp_qpqlml_quantity} corresponding to two column values returned by query.
But the above condition is not working when $F{permit_quantity} is empty or null.
I am using postgresql database
You can try to use .equals() Method if the condition itself is not working.
$F{permit_quantity}.equals(null) ? $F{fst_insp_qpqlml_quantity} : $F{permit_quantity}
There could be various other reasons why your code doesn´t work but I can´t tell from your snippet.
$F{permit_quantity}.toString() == null ? $F{fst_insp_qpqlml_quantity} :
$F{permit_quantity}
This solves your problem.