Report fields conditional

Using Specify 7, v7.9.6.2

I would like to create reports in JasperSoft with output, specifically date fields, that are conditional on values in the fields.
For null values, we can X==null?“”:Y

I would like to check the values of date fields to decide what the output is.
e.g., if an EndDate = StartDate, then only print StartDate

Or if the value of a date field is Jan. 1, e.g. 01/01/1979, just report the year:
So if {1,9-determinations.determination.determinedDateNumericDay} = 01 and {1,9-determinations.determination.determinedDateNumericMonth} = 01
then print {1,9-determinations.determination.determinedDateNumericYear}

I would also like to compare the data in two fields to decide what output is.
For example in the field collecting data, if the start and end dates are the same, then I want to print the exact date, from one of those fields. If there is a date range, then I need to print the range using only the years.

What operators allow me to do this?

Thanks

Chris

Hi @Sagebiel,

What you are seeking to do is definitely possible. I will try to show a few examples below. TLDR, .equals() may be what you are looking for:

Check if specimen is Male or Female

If the specimen is male, show :male_sign:. If female, show :female_sign:

($F{1,93.collectionobjectattribute.text1}.equals("Male")?"\u2642":"") + ($F{1,93.collectionobjectattribute.text1}.equals("Female")?"\u2640":"")

Check if month is equal to a particular value

Displays “Jan”, “Feb” etc depending on what the month is

($F{1,10.collectingevent.startDateNumericYear}==null?"":($F{1,10.collectingevent.endDateNumericYear}==null?(($F{1,10.collectingevent.startDateNumericMonth}.equals("1")?$F{1,10.collectingevent.startDateNumericYear} + "-Jan":"") + ($F{1,10.collectingevent.startDateNumericMonth}.equals("2")?$F{1,10.collectingevent.startDateNumericYear} + "-Feb":"") + ($F{1,10.collectingevent.startDateNumericMonth}.equals("3")?$F{1,10.collectingevent.startDateNumericYear} + "-Mar":"") + ($F{1,10.collectingevent.startDateNumericMonth}.equals("4")?$F{1,10.collectingevent.startDateNumericYear} + "-Apr":"") + ($F{1,10.collectingevent.startDateNumericMonth}.equals("5")?$F{1,10.collectingevent.startDateNumericYear} + "-May":"") + ($F{1,10.collectingevent.startDateNumericMonth}.equals("6")?$F{1,10.collectingevent.startDateNumericYear} + "-Jun":"") + ($F{1,10.collectingevent.startDateNumericMonth}.equals("7")?$F{1,10.collectingevent.startDateNumericYear} + "-Jul":"") + ($F{1,10.collectingevent.startDateNumericMonth}.equals("8")?$F{1,10.collectingevent.startDateNumericYear} + "-Aug":"") + ($F{1,10.collectingevent.startDateNumericMonth}.equals("9")?$F{1,10.collectingevent.startDateNumericYear} + "- Sept":"") + ($F{1,10.collectingevent.startDateNumericMonth}.equals("10")?$F{1,10.collectingevent.startDateNumericYear} + "-Oct":"") + ($F{1,10.collectingevent.startDateNumericMonth}.equals("11")?$F{1,10.collectingevent.startDateNumericYear} + "-Nov":"") + ($F{1,10.collectingevent.startDateNumericMonth}.equals("12")?$F{1,10.collectingevent.startDateNumericYear} + "-Dec":"")):$F{1,10.collectingevent.startDateNumericYear} + "-" + $F{1,10.collectingevent.endDateNumericYear}))

Further reference: https://community.jaspersoft.com/forums/topic/64172-how-to-do-string-comparison-in-condition/

1 Like