> For the complete documentation index, see [llms.txt](https://colah.gitbook.io/illuminate-bi-tool-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://colah.gitbook.io/illuminate-bi-tool-guide/jaspersoft_studio_tips_and_tricks/basics-of-writing-expressions-in-jss.md).

# Basics of Writing Expressions in JSS

Instead of “Cells”, you will be using **Fields** & **Variables** in JasperSoft.

* Fields are denoted like this: **$F{Field Name}**
* Variables are denoted like this: **$V{Variable Name}**

In the **Expression Editor**, simply **double-click on the name** of a field or variable, and it will automatically create the syntax for you.

![](http://dl.getdropbox.com/u/10575883/Expression_Editor_and_TIBCO_Jaspersoft®_Studio_Professional%203-03%20PMResize.jpg)

## Plain Text in Expressions

* Plain text in expressions should always be surrounded by double quotes (just like formulas in Excel)

## Equations

#### **Equations with Numeric Fields**

* Use **==** for numeric fields

**Example**

```
$F{Performance Level} == 4
```

#### Equations with Text Fields

* Use **.equals(“ “)** for String/Text fields

**Example:**

```
${Performance Level Text}.equals(“Proficient”)
```

#### **Does Not Equal with Numeric Fields**

* Use **!=** for numeric fields

**Example:**

```
    $F{Performance Level} != 4
```

#### **Does Not Equal with Text Fields**

* Use **!$F{Field Name}.equals(“ “)** for String/Text fields

**Example:**

```
!F{Performance Level Text.equals(“Proficient”)
```

#### Greater/Less Than or Equal To

* Use **>=**
* Do not use "==" for Greater/Less Than or Equal To

**Example:**

```
$F{Percent Correct}>=85
```

## Conditional Expressions (i.e. “If, Then” Statements):

*Learning how to write an “If Then” expression in JasperSoft studio is an essential building block for creating all sorts of reports. It is very similar to writing “IF()” formulas in Excel, but the syntax is different.*

#### **In Excel**...

* an IF() formula uses the following syntax:

`=IF(Condition, Output if True, Output if False)`

**Example**: `=IF(B2>A2,"Growth","Decline”)`

#### **In JasperSoft Studio**...

* A conditional expression uses the following syntax:

`Condition ? Output if True : Output if False`

**Example 1:**

```
    $F{Percent Correct}>=90
        ? “Mastered”
        : “Not Mastered”
```

**Example 2:**

```
    $F{Performance Level}.equals("Proficient")
        ? $F{Student ID}
        : null
```

**Example 3**:

```
    $F{2015 CELDT Level}>$F{2014 CELDT Level} 
            ? “Growth” 
            : “Decline”
```

* Syntax: **\[Condition] ? \[Output if True] : \[Output if False]**

### Nested Conditional Expressions

You can nest conditional expressions to create more complex logic statements.

**Example 1:**

```
    $F{Percent Correct}>=90 ? “Exceeding Standard” 
    :$F{Percent Correct}>=80 ? “Meeting Standard” 
    :$F{Percent Correct}>=70 ? “Approaching Standard”
    :$F{Percent Correct}<70 ? “Below Standard”
    :“Not Tested”
```

* *Note: The conditional expression will stop as soon as a condition is met, only moving on to the next condition if the preceding condition is false*.

**Example 2:**

```
$F{Grade Level}.equals("1")? 
     ($F{DRABOY}<1?"Benchmark Not Met"
    :$F{DRABOY}<=2?"Benchmark Nearly Met"
    :$F{DRABOY}<=3?"Benchmark Met"
    :$F{DRABOY}>=4?"Benchmark Exceeded" 
    :"Not Tested")
:$F{Grade Level}.equals("2")?
    ($F{DRABOY}<=12?"Benchmark Not Met"
    :$F{DRABOY}<=14?"Benchmark Nearly Met"
    :$F{DRABOY}<=16?"Benchmark Met"
    :$F{DRABOY}>=18?"Benchmark Exceeded"
    :"Not Tested")
:$F{Grade Level}.equals("3")? 
    ($F{DRABOY}<=20?"Benchmark Not Met"
    :$F{DRABOY}<=24?"Benchmark Nearly Met"
    :$F{DRABOY}<=28?"Benchmark Met"
    :$F{DRABOY}>=30?"Benchmark Exceeded" 
    :"Not Tested")
:$F{Grade Level}.equals("4")? 
    ($F{DRABOY}<=30?"Benchmark Not Met"
    :$F{DRABOY}<=34?"Benchmark Nearly Met"
    :$F{DRABOY}<=38?"Benchmark Met"
    :$F{DRABOY}>=40?"Benchmark Exceeded" 
    :"Not Tested")
:$F{Grade Level}.equals("5")? 
    ($F{DRABOY}<38?"Benchmark Not Met"
    :$F{DRABOY}==38?"Benchmark Nearly Met"
    :$F{DRABOY}<=40?"Benchmark Met"
    :$F{DRABOY}>40?"Benchmark Exceeded" 
    :"Not Tested")
:"Not Tested"
```

## “And” / “Or” Logic

* Use **&&** for “And” logic

**Example:**

```
    $F{Grade Level}.equals(“K”) && $F{Scale Score}>=220
```

* Use **||** for “Or” logic

**Example:**

```
    $F{Performance Level}.equals(“Meeting Standard”) || $F{Performance Level}.equals(“Exceeding Standard”)
```

* The “pipe” character (“ | “) key is located above the return/enter key (hold shift)
