This thread is for posting solutions to “Just KNIME It!” Challenge 4. Feel free to link your solution from KNIME Hub as well!
Here’s is my solution for the Just Knime It! Challenge 4
Here is my solution:
Hello KNIMErs,
Here is my solution to #justknimeit-4 :
KNIME Hub > gonhaddock > Spaces > Just_KNIME_It > Just KNIME It _ Challenge 004
BR
Hello!
Here’s my solution to the challenge.
just knimed it my self :))
I’m Node Golfing this question again. I’m using something that felt natural to me, but was apparently not so obvious to others, so I should mention it:
Declaring variables in the Java Snippet node at the place the editor tells us to actually creates global variables that retain their value between rows. Variables declared within the expression section do not have that property. You can read more about that in @takbb’s wonderful thread here:
That “feature” allows us to skip the lag column, because it allows the Java Snippet “retrograde row access”. It’s quite simple: Store the price value in a variable to compare against it in the next row. To prevent accessing an uninitialised variable, shortcut evaluation in if-tests is leveraged in row 0.
PS’ses:
@goodvirus your lag node drops the first row the way you configured it
@gonhaddock There’s a file with sample data in the challenge post. Your very interesting solution works with the actual data just as fine though
Solution in 4 steps
If I wanted it to be more foolproof, I would add a sort by date, and some other handlers for missing values etc.
here is my solution
Hi everyone,
Here is my solution
For those who want to have a look.
Here’s my 3-step solution:
https://kni.me/w/amVAesAJwqniUh_M
Here is my solution
the expression for calculating change column is probably the most interesting bit.
Sorry the boring solution… but is here we go
- Sorted by date just in case
- Din´t chek if there are missing data but if it is will counted as change
the node: ORDER DATES, is not necessary if the data come sorted
the node: ORDER DATES, is not necessary if the data come sorted
Just learn a new node - Lag Column !
@Thyme: Thanks for the heads up, I updated my flow. Also cool trick with the java node, that will come in handy next time I have to access the previous row and don’t want to waste memory.
Here is mine, using a similar approach like the other KNIMErs
Interesting for me was to learn about the Lag Column Node which I didn’t know and which helps me to replace those nasty MS Excel cell fixation formulas (you know, these $B5 kind of things )