Solutions to "Just KNIME It!" Challenge 04 - Season 2

Here is my solution. Fortunately this task can easily be reduced to a component where user may provide any kind of time granularity.

1 Like

Hi all,
here is my response. This is the type of seemingly simple thing i do all the time in my workflows… i did it how i always would but i have always been convinced i should be able to do this type of thing with fewer nodes. cant wait to see what you all do.
L

1 Like

Hi Everyone

I’ve made 2 solutions for this challenge, one with a loop and one without :slight_smile:

Firstly, the solution with the loop:

After reading the table, I have used a -Chunk Loop Start- node to loop through one row at a time. During each loop, a -Rule Engine- node is used to assign the Number of Rows as 12 or 4 depending on whether the Area is A or B. I have then used the -One Row to Many- node to duplicate the rows either 12 or 4 times. I have calculated the new expenditure using the -Math Formula- node by dividing the original expenditure by the Number of Rows.

In order to assign the month or quarter, I have created a new column called the Row Number, which assigns consecutive numbering to each row. A set of rules is then applied using the -Rule Engine- node:

image

I then finish the loop with a -Loop End- node and tidy up the columns.

Here is an image of the workflow:

You can find it on the Hub here:

My second solution to follow…

Thanks :slight_smile:
Heather

3 Likes

Hi again,

I’m back to explain my second version without using a loop :slight_smile:

The workflow starts with the same nodes (except the loop):

The -Rule Engine- node assigns the number of rows based on Area A or Area B and the -One Row to Many- node duplicates rows 12 or 4 times respectively. The new expenditure is calculated using the -Math Formula- node and then a consecutive row count is generated using another -Math Formula- node.

The next part of the workflow uses the following nodes:

The -Rank- node is then used to rank each row per area/project, so projects in Area A will each be assigned a rank from 1-12 and projects in Area B will each be assigned a rank from 1-4.

Afterwards, the -Row Splitter- node is used to separate rows based on Area. For those in Area A, a Date is created using the -String Manipulation- node by joining the Year, Rank and “01” to create a date for the 1st of each month. After being converted from String to Date format, the month is then extracted as a name using the -Extract Date&Time Fields- node. This name can then be shortened to 3 letters using the -String Manipulation- node.

For Area B, the -String Manipulation- node is used to join “Q” and the rank, therefore creating the time period e.g. “Q1”

Area A is then concatenated with Area B and the columns are filtered and tidied up.

I used the -Timer Info- node to compare the time taken to run this solution versus my previous one, which shows that the workflow without the loop is faster.

You can find the workflow on the hub:

Hope you enjoy both solutions this week :slight_smile:
Thanks
Heather

2 Likes

Here’s my solution for JKISeason2-4: Spread Yearly Values Across Months

For this challenge, I tried to make it dynamic:

  1. I added a widget that allows you to select whether the distribution is monthly or quarterly.
  2. Based on the distribution type, I created date ranges.
  3. I used these date ranges to distribute the annual values either monthly or quarterly.

Leave the workflow in a way that as new years are added, they are distributed automatically and there is no need to modify the workflow.

Thank you!


1 Like

My take on the challenge:

KNIME_project challenge.knwf (83.6 KB)

Here is my solution.
I splitted the table in Area A and Area B, created additional tables with months’ names and quarters’ description, and used Cross Joiner to create the final table.

Regards

1 Like

Impressive in terms of least node used, very sustainable :slight_smile:

1 Like

:mega: As always on Tuesdays, here’s the solution to last week’s Just KNIME It! challenge! :partying_face:

Just like in a few of the solutions above, this one also relies heavily on the Cross Joiner node :twisted_rightwards_arrows:. Had you ever used this node before? Pretty costly and yet very powerful – great for applications where the data is not very large, which is the case here.

:boom: We hope you enjoyed this challenge and hope to see you tomorrow for a new one! :nerd_face:

5 Likes

Here is #4, managing without loops but then get a few extra nodes in use.

1 Like

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