# 💡 Announcement: Extended expression syntax

**URL:** <https://community.easymorph.com/t/announcement-extended-expression-syntax/1821>\
**Category:** General Q&A\
**Created:** [April 29, 2020, 2:55pm UTC](https://community.easymorph.com/t/announcement-extended-expression-syntax/1821 "2020-04-29T14:55:32Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![dgudkov](https://community.easymorph.com/user_avatar/community.easymorph.com/dgudkov/32/5_2.png) [@dgudkov](https://community.easymorph.com/u/dgudkov)\
**Post date:** [April 29, 2020, 2:55pm UTC](https://community.easymorph.com/t/announcement-extended-expression-syntax/1821/1 "2020-04-29T14:55:33Z")

</div>

We're working on a new, extended expression syntax in v4.4 that is planned for release by the end of May. The changes:

### Unary minus operator

It will be possible to use the unary minus. So instead of writing

```
addmonths([Date], 0 - 1)

```

it will be possible to write

```
addmonths([Date], -1)

```

Long due. I know 🙂

### Local constants

We're introducing constants in expressions. Constants must be assigned using the `let` operator before they can be used in expression. Syntax:

```
//Constant assignment.
let a = ([A] + [B]) / [C] // Some complex expression

//Use of constant in expression.
([D] + a) / ([E] - a)

```

Constants should help make expressions more readable. They also eliminate the need to create temporary columns in some cases.

### IF/THEN/ELSE operator

Since the very early versions EasyMorph has been offering the if() function which works similarly to the IF() function in Excel.

Now, for better readability of expressions we're adding the IF/THEN/ELSE operator, which is well known for Tableau users. Example:

```
IF isempty([FX Rate]) THEN error("Missing FX rate!") ELSE [Amount] * [FX Rate]

```

The ELSE statement is optional. If omitted it returns an empty value.

```
//If FX rate is empty the result will be empty too.
IF not isempty([FX Rate]) THEN [Amount] * [FX Rate]

```

Question to our users: how do these improvements look to you?

---

<div class="post-metadata">

**Author:** ![dgudkov](https://community.easymorph.com/user_avatar/community.easymorph.com/dgudkov/32/5_2.png) [@dgudkov](https://community.easymorph.com/u/dgudkov)\
**Post date:** [April 29, 2020, 3:01pm UTC](https://community.easymorph.com/t/announcement-extended-expression-syntax/1821/2 "2020-04-29T15:01:31Z")

</div>



---

<div class="post-metadata">

**Author:** ![RJO](https://community.easymorph.com/user_avatar/community.easymorph.com/rjo/32/4084_2.png) [@RJO](https://community.easymorph.com/u/RJO)\
**Post date:** [May 6, 2020, 1:39pm UTC](https://community.easymorph.com/t/announcement-extended-expression-syntax/1821/3 "2020-05-06T13:39:40Z")

</div>

I have business users so constants in "let" expression is a bit complex for them. Maybe it could be good to have a third tab : columns, parameters AND variables, even if it's only for the current expression. You would be able to define variables there, so no "let" syntax and you can drag and drop like columns/parameters.

For unary minus, it was so much expected, thank you !!!

The IF syntax on the contrary of "let" is better for business users, clearer than coder syntax with "(" and ";". Well that's our point of view. It's good !

---

<div class="post-metadata">

**Author:** ![dgudkov](https://community.easymorph.com/user_avatar/community.easymorph.com/dgudkov/32/5_2.png) [@dgudkov](https://community.easymorph.com/u/dgudkov)\
**Post date:** [May 20, 2020, 9:32am UTC](https://community.easymorph.com/t/announcement-extended-expression-syntax/1821/4 "2020-05-20T09:32:45Z")

</div>

Here is a practical example. Which reads better?

This:

```
padstart(isoweeknumber([Date]), '0', 2) & '-' & padstart(if(isoweeknumber([Date]) = 1 and month([Date]) = 12, year([Date])+1, year([Date])), '0', 2)

```

Or this:

```auto
let week = isoweeknumber([Date])
let yr = year([Date])

//attribute the last incomplete week to the next year
let year = (IF week = 1 and month([Date]) = 12 THEN yr+1 ELSE yr)

padstart(week, '0', 2) & '-' & padstart(year, '0', 2)

```

---

<div class="post-metadata">

**Author:** ![reynsnivea](https://community.easymorph.com/letter_avatar_proxy/v4/letter/r/9f8e36/32.png) [@reynsnivea](https://community.easymorph.com/u/reynsnivea)\
**Post date:** [May 24, 2020, 7:02pm UTC](https://community.easymorph.com/t/announcement-extended-expression-syntax/1821/5 "2020-05-24T19:02:34Z")

</div>

Hi Dmitry,

Very good improvements ! Will existing projects that contain the old syntax will continue to run correctly after the update?

Maybe the "let" keyword is not that clear. Personally I would prefer "var" but I consider it a detail. I know that javascript also uses the "let" keyword.

Any plans to introduce some syntax highlighting, autocompletion and auto-indentation in the expression builder as expressions will become more complex due to the new possibilities?

Thanks !  
Nikolaas

---

<div class="post-metadata">

**Author:** ![dgudkov](https://community.easymorph.com/user_avatar/community.easymorph.com/dgudkov/32/5_2.png) [@dgudkov](https://community.easymorph.com/u/dgudkov)\
**Post date:** [May 25, 2020, 9:15am UTC](https://community.easymorph.com/t/announcement-extended-expression-syntax/1821/6 "2020-05-25T09:15:00Z")

</div>

> [@reynsnivea](#):
>
> Any plans to introduce some syntax highlighting, autocompletion and auto-indentation in the expression builder as expressions will become more complex due to the new possibilities?

This will appear at some point, but not in the next few releases. The only addition in the next release will be highlighting of syntax errors.

---

<div class="post-metadata">

**Author:** ![dgudkov](https://community.easymorph.com/user_avatar/community.easymorph.com/dgudkov/32/5_2.png) [@dgudkov](https://community.easymorph.com/u/dgudkov)\
**Post date:** [May 25, 2020, 9:16am UTC](https://community.easymorph.com/t/announcement-extended-expression-syntax/1821/7 "2020-05-25T09:16:41Z")

</div>

> [@reynsnivea](#):
>
> Will existing projects that contain the old syntax will continue to run correctly after the update?

Yes, the new syntax is an extension of the old one. Expressions in old projects will keep working without any changes.

---

<div class="post-metadata">

**Author:** ![reynsnivea](https://community.easymorph.com/letter_avatar_proxy/v4/letter/r/9f8e36/32.png) [@reynsnivea](https://community.easymorph.com/u/reynsnivea)\
**Post date:** [May 25, 2020, 11:48am UTC](https://community.easymorph.com/t/announcement-extended-expression-syntax/1821/8 "2020-05-25T11:48:56Z")

</div>

Geat !

---

<div class="post-metadata">

**Author:** ![dgudkov](https://community.easymorph.com/user_avatar/community.easymorph.com/dgudkov/32/5_2.png) [@dgudkov](https://community.easymorph.com/u/dgudkov)\
**Post date:** [May 26, 2020, 8:57pm UTC](https://community.easymorph.com/t/announcement-extended-expression-syntax/1821/9 "2020-05-26T20:57:49Z")

</div>

Here is what error highlighting will look like.

 ![image](https://community.easymorph.com/uploads/default/original/2X/c/cf27c7f1a2fbe9d0d09e9e332de84cc6f8a99d09.png)

---

<div class="post-metadata">

**Author:** ![reynsnivea](https://community.easymorph.com/letter_avatar_proxy/v4/letter/r/9f8e36/32.png) [@reynsnivea](https://community.easymorph.com/u/reynsnivea)\
**Post date:** [June 9, 2021, 8:13am UTC](https://community.easymorph.com/t/announcement-extended-expression-syntax/1821/10 "2021-06-09T08:13:38Z")

</div>

Hi Dmitry,

Is a further extension of the formula editor with syntax highlighting and autocompletion (dropdown of columns, variables, functions, etc. as you type) also on the roadmap ?

This could be a great feature.

Kind regards  
Nikolaas

---

<div class="post-metadata">

**Author:** ![dgudkov](https://community.easymorph.com/user_avatar/community.easymorph.com/dgudkov/32/5_2.png) [@dgudkov](https://community.easymorph.com/u/dgudkov)\
**Post date:** [June 9, 2021, 2:18pm UTC](https://community.easymorph.com/t/announcement-extended-expression-syntax/1821/11 "2021-06-09T14:18:42Z")

</div>

No plans for syntax highlighting so far. It's not a priority at this point.

---

<div class="post-metadata">

**Author:** ![reynsnivea](https://community.easymorph.com/letter_avatar_proxy/v4/letter/r/9f8e36/32.png) [@reynsnivea](https://community.easymorph.com/u/reynsnivea)\
**Post date:** [June 10, 2021, 6:20am UTC](https://community.easymorph.com/t/announcement-extended-expression-syntax/1821/12 "2021-06-10T06:20:56Z")

</div>

Ok thanks for the update.
