# Expression Node - I simply do not understand its inner workings

**URL:** <https://forum.knime.com/t/expression-node-i-simply-do-not-understand-its-inner-workings/86746>\
**Category:** Feedback & Ideas\
**Created:** [February 28, 2025, 12:37pm UTC](https://forum.knime.com/t/expression-node-i-simply-do-not-understand-its-inner-workings/86746 "2025-02-28T12:37:19Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![kowisoft](https://forum-cdn.knime.com/user_avatar/forum.knime.com/kowisoft/32/3295_2.png) [@kowisoft](https://forum.knime.com/u/kowisoft)\
**Post date:** [February 28, 2025, 12:37pm UTC](https://forum.knime.com/t/expression-node-i-simply-do-not-understand-its-inner-workings/86746/1 "2025-02-28T12:37:20Z")

</div>

Dear KNIMErs,

I really have difficulties in understanding how the Expression nodes work. Especially now since it has officially replaced a lot of the “old nodes” (like Rule Engine, String Manipulation etc)

Let me give you an example.

I have a column holding date differences as an integer.

I want to categorize this in 3 different categories:  
0 - 30 days  
31 - 60 days

> 60 days

In the “old world” I would have used a Rule Engine, that was easy to understand and even kind of visual (with its =\> operator)

Diff \>= 0 AND Diff \<= 30 =\> “cat 1”  
Diff \>= 31 AND DIFF \<= 60 =\> “cat 2”  
TRUE =\> “cat 3”

Easy peasy.

Now in Expressions, K-AI suggests switch or If which are both explained in a kind of confusing way.

I want to use the most up to date nodes because I think they offer some great opportunities, but right now for me this feels like a big step backwards, tbh.

ps: the KNIME forum software does not seem to accept line breaks anymore…

---

<div class="post-metadata">

**Author:** ![mwiegand](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mwiegand/32/66896_2.png) [@mwiegand](https://forum.knime.com/u/mwiegand)\
**Post date:** [February 28, 2025, 12:52pm UTC](https://forum.knime.com/t/expression-node-i-simply-do-not-understand-its-inner-workings/86746/2 "2025-02-28T12:52:11Z")

</div>

Hi @kowisoft,

you are not alone. I too struggle to put it to proper use. Maybe this PDF helps you?

> **[knime\_expressions\_guide.pdf](https://docs.knime.com/latest/knime_expressions_guide/knime_expressions_guide.pdf)**
>
> 1900.21 KB

The new Expression Nodes purpose is to:

> Enables row-by-row data manipulation to add or replace columns.

So it would be like shooting with canon balls on flies. Why not use a simple biner with evenly spaced bins like so?

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/8/2/82d4a9e7db2a7fafb6928c4ab8697d3ee547a1df.png)

Here is the (possible) solution:

> **[86746 - Categorize or bin numbers – mwiegand](https://hub.knime.com/mwiegand/spaces/Public/Knime%20Forum%20Support/86746%20-%20Categorize%20or%20bin%20numbers~aWhBloJjtaMaQJf-/current-state)**
>
> Solutions for data science: find workflows, nodes and components, and collaborate in spaces.

Best  
Mike

---

<div class="post-metadata">

**Author:** ![kowisoft](https://forum-cdn.knime.com/user_avatar/forum.knime.com/kowisoft/32/3295_2.png) [@kowisoft](https://forum.knime.com/u/kowisoft)\
**Post date:** [February 28, 2025, 12:54pm UTC](https://forum.knime.com/t/expression-node-i-simply-do-not-understand-its-inner-workings/86746/3 "2025-02-28T12:54:33Z")

</div>

you are probably right, it actually IS shooting with canons at flies.

The thing is I tried to use the Expressions node quite a few times as a replacement for some of the older nodes (as per the KNIME learning curriculum) and have found it more complicated (personal opinion here!)

I definitely want to use it because it seems to offer some great opportunities, however, I was not able to realize them (that probably will come)…

Thanks for the guide though.

---

<div class="post-metadata">

**Author:** ![mwiegand](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mwiegand/32/66896_2.png) [@mwiegand](https://forum.knime.com/u/mwiegand)\
**Post date:** [February 28, 2025, 12:59pm UTC](https://forum.knime.com/t/expression-node-i-simply-do-not-understand-its-inner-workings/86746/4 "2025-02-28T12:59:10Z")

</div>

> [@kowisoft](#):
>
> and have found it more complicated (personal opinion here!)

You are not alone. During the community hacking days some feedback was given about the new expression node. Personally, I feel it attempts to become a “Eierlegende Wollmilchsau” and presents a step away from Knimes core concept of Codeless. I alse do not see what exact problem this nodes solves in the first place except polishing the UI. Anyways, different topic.

Coming back to your original challenge, the expression node would be useful in case you want to determine if the days diff between the current and the next row falls into a certain bucket.

Shall I hack somethigng together for you?

---

<div class="post-metadata">

**Author:** ![kowisoft](https://forum-cdn.knime.com/user_avatar/forum.knime.com/kowisoft/32/3295_2.png) [@kowisoft](https://forum.knime.com/u/kowisoft)\
**Post date:** [February 28, 2025, 1:03pm UTC](https://forum.knime.com/t/expression-node-i-simply-do-not-understand-its-inner-workings/86746/5 "2025-02-28T13:03:27Z")

</div>

thanks a lot, Martin. Not necessary to do something. Because I have cut my ego a bit and instead of “wanting to use the Expressions Node” I simply used the good old Rule Engine. Why go for something more complex, when this is not necessary…?

---

<div class="post-metadata">

**Author:** ![nan](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/n/cc9497/32.png) [@nan](https://forum.knime.com/u/nan)\
**Post date:** [February 28, 2025, 1:06pm UTC](https://forum.knime.com/t/expression-node-i-simply-do-not-understand-its-inner-workings/86746/6 "2025-02-28T13:06:04Z")

</div>

Hi @kowisoft ,

the new syntax is like this:

```auto
if(0 <= $Diff and $Diff <= 30, “cat 1”,
   31 <= $Diff and $Diff <= 60, “cat 2”,
   “cat 3”)

```

We also thought about a more visual replacement for the Rule Engine that would split up the big input field and make the rules more visual. However, we parked that idea for now, since the “if” function with one rule per row – as in the example – is very close to what the Rule Engine looks like. I agree though, that the old “=\>” had a more visual appeal than the comma in the new syntax.

Just in case you want to reconsider using the Expression node,  
nan

---

<div class="post-metadata">

**Author:** ![MartinDDDD](https://forum-cdn.knime.com/user_avatar/forum.knime.com/martindddd/32/69988_2.png) [@MartinDDDD](https://forum.knime.com/u/MartinDDDD)\
**Post date:** [February 28, 2025, 6:55pm UTC](https://forum.knime.com/t/expression-node-i-simply-do-not-understand-its-inner-workings/86746/7 "2025-02-28T18:55:24Z")

</div>

let me chime in here - I agree that Expressions Node is not perfect, but honestly I enjoy the opportunity to solve different kinds of rather simple problems with one node - if I have access I “cheat” and ask K-AI to do something for me and that is the appeal.

That said I feel like I am starting to get used to the new syntax and despite some inconsistencies (some functions reference columns as “column1”, others require the $ signs etc…) I start to like it 🙂

---

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [March 1, 2025, 6:54am UTC](https://forum.knime.com/t/expression-node-i-simply-do-not-understand-its-inner-workings/86746/8 "2025-03-01T06:54:17Z")

</div>

@nan if, then, else operations are the most common used and I also [was initially struggling](https://medium.com/low-code-for-advanced-data-science/knime-snippets-3-rules-and-conditions-do-apply-72b6ffbd4c9f#:~:text=the%20(new)%20expression%20node) how the new node does handle that. Since I also was not able to find a hint in the documentation.

---

<div class="post-metadata">

**Author:** ![mwiegand](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mwiegand/32/66896_2.png) [@mwiegand](https://forum.knime.com/u/mwiegand)\
**Post date:** [March 1, 2025, 9:55am UTC](https://forum.knime.com/t/expression-node-i-simply-do-not-understand-its-inner-workings/86746/9 "2025-03-01T09:55:12Z")

</div>

I took some time to replicate the rules from a Rule Engine in the Expression Node to better display the discomfort the new Expression Node causes:

**Rule Engine**

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/c/2/c2972fddfa4ea1a58ca47769a3004c657a770e11.png)  
1.750 Characters

**Expression Node**

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/7/8/784089dc9670e5474c098a9a84dc5698a7b587d1.png)  
1.958 Characters (+11 %)

- Rule Engine offers much better syntax highlighting
- Rule Engine clearly separated from Result using `=>` syntax
- Rule Engine logic operators `AND, `OR` better recognizable
- Typography provides a better contrast (font weight regular vs. light, background color light blue … why???)
- No excessive nesting (likely bcs. of missing elseif in Expression Node Syntax), making logic easier to follow
- Colors help differentiate rules and conditions
- Variable types better distinguishable in Rule Engine

**Error handling**  
Rule Engine

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/b/d/bd1cc6f761c6f0a70e2d83dcc46a81cf3faba92b.png)  
Clear visibility

Expression Node

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/e/6/e6e3edfa14a9eada5c2be1fe69ccdf41cdfe40d1.png)  
Poor visibility

**Variables**  
Rule Engine  
 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/3/c/3c5c4ec41f0243d3dbf96deac3455e9de0b3da20.png)

Expression Node

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/6/0/609663c8eb8fa3e60932c8488f677e3194cbed80.png)

Suggestions

1. Replace the light blue by a regular white background
2. Switch to regular or medium font size
3. Improve syntax highlighting (brackets, variables vs. column references, operators)
4. Code Consistency / Flexibility: Comparisons like `==` are allows but `&&` instead of and ain’t. if-Clause is supported but not elseif
5. Add Auto-Indentation and option to press CTRL+A \> Shift+Tab

Any maybe more but I’d like to invite others to provide their “two cents” too 😉 Enjoy your weekend …

Best  
Mike

---

<div class="post-metadata">

**Author:** ![schulz\_d](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/s/839c29/32.png) [@schulz\_d](https://forum.knime.com/u/schulz_d)\
**Post date:** [March 3, 2025, 9:09am UTC](https://forum.knime.com/t/expression-node-i-simply-do-not-understand-its-inner-workings/86746/10 "2025-03-03T09:09:33Z")

</div>

Big +1 for Mike’s suggestions.

It feels especially alienating for me because the “old” column and variable expressions node were such good additions, and the new node feels very lackluster in comparison. Additionally, it introduces yet another new “programming” syntax to learn in Knime.

My suggestions:

- Fewer comments at the start of an expression. Especially in the embedded view, it is really hard to see the first empty line to write on.
- Make expressions even more distinguishable from one another, perhaps by graying out the inactive ones.
- Collapsing the expressions would help with clarity as well. Take inspiration from the old column expressions node, where you first had to click on the expression to see the code.
- Add more information in the header of an expression, such as indicating which row is replaced or appended. Another option is to allow users to give it a custom name.

And lastly a more personal one: Please change the syntax of the If statements! I understand the intent to have it like a Excel formula but like in Excel it is just hard to read and feels really unnatural with a programming background.

Best regards,  
David

---

<div class="post-metadata">

**Author:** ![MartinDDDD](https://forum-cdn.knime.com/user_avatar/forum.knime.com/martindddd/32/69988_2.png) [@MartinDDDD](https://forum.knime.com/u/MartinDDDD)\
**Post date:** [March 3, 2025, 9:17am UTC](https://forum.knime.com/t/expression-node-i-simply-do-not-understand-its-inner-workings/86746/11 "2025-03-03T09:17:36Z")

</div>

given the inputs provided I have moved this to Feedback & Ideas 🙂

---

<div class="post-metadata">

**Author:** ![takbb](https://forum-cdn.knime.com/user_avatar/forum.knime.com/takbb/32/57077_2.png) [@takbb](https://forum.knime.com/u/takbb)\
**Post date:** [March 3, 2025, 2:01pm UTC](https://forum.knime.com/t/expression-node-i-simply-do-not-understand-its-inner-workings/86746/12 "2025-03-03T14:01:24Z")

</div>

Could I add a +1 to @mwiegand’s earlier comments that the font colour and weight provide poor visibility compared with the older nodes .

For me the new Expression nodes (and the new Python scripting nodes) are incredibly tiring on the eyes for prolonged use as they are difficult to read. (I feel like I’m reading it through a light fog)

Maybe when I was younger, with better eyes, I’d have been ok, but not these days!

All modern IDEs provide the ability to set the colour scheme according to user preference, and need, but with no ability to change the colours and font weight, the chosen scheme should at least be practical rather than what appears to be “form over function” and simply _dim-and-faint-for-the-sake-of-it._

I really hope such comments are taken on board because being able to read the screen easily shouldn’t be a “nice to have”.

---

<div class="post-metadata">

**Author:** ![mwiegand](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mwiegand/32/66896_2.png) [@mwiegand](https://forum.knime.com/u/mwiegand)\
**Post date:** [March 3, 2025, 4:23pm UTC](https://forum.knime.com/t/expression-node-i-simply-do-not-understand-its-inner-workings/86746/13 "2025-03-03T16:23:57Z")

</div>

Knowing the MUI (Modern UI) is HTML based, I was hoping to find the CSS but couldn’t spot it so far. Maybe I wasn’t looking deep enough …

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [March 10, 2025, 4:24pm UTC](https://forum.knime.com/t/expression-node-i-simply-do-not-understand-its-inner-workings/86746/14 "2025-03-10T16:24:10Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
