Expression Functions

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

Functions can be used inside of expressions to do many interesting things such as turning a column of text into all capitol letters.

A function can be called with the systax: ${rw:functionName(param1,param2...)}

The following are each of the included functions on how to use them.

Note: Clicking the fx button when working on an expression column will give you the full (updated) list of available expressions and functions:



Click Here to download the full reference sheet of built-in expression functions


removeEols(value)

Description:

Removes any end of line characters from a string

Example Usage:

rw:removeEols(row.description)

convertIfPossibleToInteger(someString)

Description:

Tries really hard to convert the string to an integer.  For example if you pass it "74 Colonial Rd." it will return 74.

It will convert to an integer the first full number it finds.  

toInteger(value1)

Description:

Returns as an integer; any type of value1.

toDouble(value1)

Description:

Returns as a double; any type of value1.

toBigDecimal(value1)

Description:

Returns as a Big Decimal; any type of value1.

Concat(value1, value2) and concat3..5

Description:

Concatenate 2 strings together

Example Usages:

${rw:concat(row.courseCode, row.courseSection)}

${rw:concat3(row.courseCode, '-', row.courseSection)}

${rw:concat5(row.courseCode, '-', row.courseSection, '.' , row.subsection)}

length(stringValue)

Description: 

Returns the length in characters of a string value.

Example Usages:

${rw:length(row.lastName)}

trim(stringValue)

Description: 

Returns the string value minus any extra white space characters.

Example Usages:

${rw:trim(row.lastName)}

getDayOfYear(date)

Description:

Returns the day number in the year.

2/1/2011 would return 32

getNumberOfDays(fromDate, thruDate)

Description:

Calculate the number of days between 2 dates inclusively.

If fromDate = thruDate this will return 1

formatNumber(dateValue, 'date format')

 Description: 

 Formats a number given a format string

 #

0

.

Example Usages:

${rw:formatNumber(row.gpa,'0000.00')}


formatDate(dateValue, 'date format')

Description: 

Formats a date given a format string/

yy = year
dd = day
MM = Month
hh = hour
mm = minute
ss = second
aa = am/pm

Example Usages:

${rw:formatDate(row.dateOfBirth,'yyyy-MM-dd')}  '

substring(value, startPosition, length)

Description: 

Returns a substring of value.

startPosition 0=first character

length number of characters to extract

Example Usages:

${rw:substring('Hello World', 0,5)}    returns 'Hello'

getCodeDescription(setCode, code)

Description: 

Lookup the description from the Setup.Codes screen.

setCode = The set to look for (LANGUAGE_CODES for example)

code = The code to lookup

Example Usages:

${rw:getCodeDescription('LANGUAGE_CODE', row.homeLanguageCode)}

findCycleCode(date1, schoolCode, type)

Description: 

date1 is the date to search on

schoolCode the school's attendance cycles to search in

Types are: Exam,Final Grade,Marking Period,Interim Report Period,Month,School Year,Season,Semester,Single Day,Sports Season

Example Usages:

${rw:findCycleCode(today,param.SCHOOL_CODE,'Marking Period')}

getCycleStartDate(schoolCode, cycleCode)

Description: 

Return the start date of the cycleCode in schoolCode

Example Usages:

${rw:getCycleStartDate(param.SCHOOL_CODE,'MP1')}

getCycleEndDate(schoolCode, cycleCode)

Description: 

Return the end date of the cycleCode in schoolCode

Example Usages:

${rw:getCycleEndDate(param.SCHOOL_CODE,'MP1')}

dateCompare(date1, date2 )

Description: 

returns a number describing the relationship of date1 and date2

0 = Same Date

1 = Date2 after Date1

-1 = Date2 is before Date1

Example Usages:

${rw:toDate('09/01/2011')}

dateFindDayOfWeek(date, dayToFind, weekOffset)

Description: 

Locate the nearest day of the week.

date - The date to start with

dayToFind - A String of the day of the week (Monday, Tuesday etc..)

weekOffset = 0 = this week, -1 last week, 1 next week etc...

Example Usages:

${rw:dateFindDayOfWeek(row.someDate,'Monday', 0)}

toDate(textValueOfADate)

Description: 

Converts text representation of a date to a real date value.

Example Usages:

${rw:toDate('09/01/2011')}

dateAddDays(dateValue, daysToAdd)

Description: 

Add or subtract days from the given date value.

Example Usages:

${rw:dateAddDays(row.registrationDate,10)}
${rw:dateAddDays(row.registrationDate,-10)}

contains(value, testValue)

Description: 

Returns true if value contains testValue

Example Usages:

${rw:contains(row.fullName,'Zinn')}

in(list values, testValue)

Description: 

Returns true if any values in the list are contained within testValue

Example Usages:

${rw:in('08,09,10' , row.gradeLevel)} returns 'Y' if grade level = '08' or '09' or '10'

startsWith(value, testValue)

Description: 

Returns true if value contains starts with testValue

Example Usages:

${rw:startsWith(row.lastName,'Z')}

endsWith(value, testValue)

Description: 

Returns true if value contains ends with testValue

Example Usages:

${rw:endsWith(row.lastName,'inn')}

indexOf(value, subString, startingPosition)

Description: 

Returns the position of subString within value.

-1 if string is not found.

First position in value is 0

Example Usages:

${indexOf(row.lastName,'i',0)}

   Returns 1 where lastName = 'Zinn';

initCaps(value)

Description: 

Convert the value to all lower case characters; then convert the first letter of each word to uppercase.

Example Usages:

${rw:toUpperCase(row.fullName)}

   This would convert "CHRIS ZINN" to "Chris Zinn"

toLowerCase(value)

Description: 

Convert the value to all lower case characters.

Example Usages:

${rw:toUpperCase(row.lastName)}

replaceChars(value,from,to)

Description: 

Change all instances of from with to in the string value

Example Usages:

This will replace all Zs with Rs

${rw:replaceChars(row.lastName, 'Z', 'R')}

${rw:replace(row.lunchCode,'R','Reduced')}

replace(value,from,to)

Description: 

Convert value to from if value == to

Example Usages:

The following example would replace F with Free and R with Reduced in a column "lunchCode"

${rw:replace(row.lunchCode,'F','Free')}

${rw:replace(row.lunchCode,'R','Reduced')}

Notice how the two expressions are placed side by side. 

booleans will always come into this function as the word true

for examplle: ${rw:palce(row.booleanValue,'true','True')}

toUpperCase(value)

Description: 

Convert the value to all upper case characters.

Example Usages:

${rw:toUpperCase(row.lastName)}

rw:randomNumber(x)

Description:   Generates a random number between 1 and 'x'

Example Usage:   ${rw:randomNumber(100)}


Conditional Expression

Ternary operators may be used in expression column.

Example 1:

${row.examName=='ELA03'  && row.numericScore6>700?"4":"" || row.examName=='ELA03' && row.numericScore6>800?"5":""}

This example tells the report writer that IF the rows ExamName is equal to "ELA03" and ("&&") the NumericScore is greater than 700, then ("?") display "4" ELSE (":") display nothing ("").  The "II" (or) tells report writer to also check to see if the ExamName is "ELA03" and NumericScore is grater than 800, to display the text "800".

Example 2:

${empty row.exampleColumn ? "Y" : ""}

The above is an example of an expression column that simply identifies if the field described is "blank" or "null" and if so, the report writer will input a "Y" in the expression column. If not, it will remain blank. This becomes useful when setting up a parameter on the front of the report, where a user can select "Y" from a dropdown, if they only want to output records where the example column is blank.

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