Expression Language Operators

Modified on Tue, Nov 28, 2023 at 9:13 AM


Click Here for a full list of expression functions 


Expression Language is Very Flexible

The Expression Language itself is very powerful and flexible.  “Expression Language” is what can occur between the “${“ open bracket and “}” close bracket.   What can occur there includes the following:

-          References to columns preceding the current Expression column in the list of columns:

  • Columns in the next row of output are referenced by saying ‘nextRow.column’.  E.g. ${nextRow.studentName}, ${nextRow.gender}, ${nextRow.dateOfBirth}.
  • Columns in the previous row of the report are referenced by saying ‘prevRow.column’.  E.g. ${prevRow.studentName}, ${prevRow.gender}, ${prevRow.dateOfBirth}.

-          Parameters to the Report including both the built-in set of parameters and ‘user defined macros’ or parameters that you create on the Parameters tab of the Report.   E.g. ${params.SchoolYear}.

-          Literal strings.  E.g. “Y”, “N”, “Daughter”, “Guardian 1”, etc.

-          Literal numbers.  Including:

  • Integers  17  922019
  • Decimal (floating point) numbers:  24.7   0.44
  • Exponential numbers: 1.2E4 (1.2 * 10**4 or 12000)

-          Built-In Functions:  A number of functions are provided by the ReportWriter Expression language.   These can all appear in expressions.  E.g. ${rw:toUpperCase(row.studentName)}

-          Expression Language Operators:  All of the ‘operators’ listed in the table below, including:

  • Conditional Expressions – “IF” statements that result in decisions being made within the column itself.  See below the “Making Decisions in a Report” section.
  • Logical operators - which are always true or false
  • Relational operators - which are also always true or false
  • Arithmetic operations – which always result in numeric values.

-          But NOT Dates:   Dates cannot be input directly.  E.g. 12/24/2011 becomes a STRING, not a DATE.  Dates must be converted from Strings to an actual DATE via the ‘toDate’ Function.   See below.



Operators

The full list of operators, values and functions that can appear in ‘expressions’ is below:


Expression Language Operators, Functions & Values

Examples

Arithmetic Operators


+

Add


-

Subtract


*

Multiply


/

Divide


%

Modulo (integer remainder) – Finds the remainder

10%4 = 2

Logical Operators


!

Not   - unary ‘not’ operator.  Reverses the truth of a test value.

!A   or !empty

||

Or  - A || B   means ‘A or B’ – Either A or B must be true

A || B

&&

And  - A && B   means ‘A and  B’ must both be true

A && B

Relational Operators


==

Equal to

A == B  or A eq B

!=

Not equal to

A != B  or A ne B

Less than

A < B or A lt B

<=

Less than or equal to

A <= B or A le B

Greater than

A > B or A gt B

>=

Greater than or equal to

A >= B or A ge B

String compare functions


Contains

Test whether the column “contains” a certain String.  Returns true/false.

rw:contains()

startsWith

Test whether the column “starts with” a certain String. Returns true/false.

rw:startsWith()

endsWith

Test whether the column “ends with” a certain String.  Returns true/false.

rw:endsWith()

Date Compare


dateCompare(date1, date2)

Returns an integer value:
0 – same date (date1==date2)
-1 – Date2 is earlier than Date 1
1 – Date 2 is later than Date 1

rw:dateCompare(today, params.startDate)

Programmatic


empty

Is the field empty?


!empty

Does the field have something in it? (is it not empty?)


Conditional Operator


?:

A? B : C – If A, then B else C


Special Values


true

Logical “true”.  “Y” to the ReportWriter


false

Logical “false”.  “N” to the ReportWriter


null

“Empty” – for testing fields


String Functions – These are provided to work with Strings


toUpperCase

Convert String to all upper case

rw:toUpperCase( params.SCHOOL_NAME)

toLowerCase

Convert String to all lower case

rw:toLowerCase(row.emailAddr)

initCaps

Convert String to all lower case then capitalize the first letter of each word

rw:initCaps(row.lastName)

Replace

Replace one piece of text with another

re.replace(row.lunch,”F”,”Free”)

Date Functions – These are provided to work with Dates


toDate

Convert a date String to an actual DATE.

rw:toDate(“07/24/2011”)

dateAddDays

Add X days to the startDate.  X can be +-

rw:dateAddDays(row.aDate, -1)  == yesterday

dateFindDayOfWeek

Find the “next X day”  E.g. Find next Monday plus X weeks

rw:dateFindDay(today,”Mon”, 0)  – Find next Monday

findCycleCode

Find the cycle of type type in which the Date falls,

rw:findCycleCode(today, params.SCHOOL_CODE,  “Sports Season”)

getCycleStartDate

Find the first date in the cycle

rw:getCycleStartDate( params.SCHOOL_CODE,
params.selectMP)

getCycleEndDate

Find the last date in the cycle

rw:getCycleEndDate( params.SCHOOL_CODE,
params.selectMP)

getNumberOfDays

Get the number of days between two dates

rw:getNumberOfDays(fromDate,thruDate)

getDayOfYear

Get the numberical day of the year. E.g. Jan 24th is the 24th day of the year

rw:getDayOfYear(date)

Lookup Functions – Provided to lookup Descriptions for Generic Codes in Genesis

getCodeDescription

Lookup a Generic Code’s Description

rw:getCodeDescription('LANGUAGE_CODE', row.homeLanguageCode)

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article