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)
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…
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)…
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.
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…?
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
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
@nan if, then, else operations are the most common used and I also was initially struggling how the new node does handle that. Since I also was not able to find a hint in the documentation.
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.
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”.