How to divide column by column n-5 for multiple UIs?

Hi everyone,

I have a set of data with the following columns:

  • Part Nr
  • StorageLocation
  • Site
  • NV1
  • NV2
  • Quantities in monthly columns such as “2017-01-01”, 2017-02-01", etc. (up to “2022-12-01”)

As Step 1) I created new columns such as “MA(2017-06-01)” by means of the Moving Average Node for each UI. My UI is a concatenate of the 3 columns “Part Nr-StorageLocation-Site”.

As Step 2) for each UI, I would like to divide a column “MA(2017-10-01)” by “MA(2017-06-01)”.

For an example please look at the attached picture below (the input data can be found in the attached example file AverageMultipleColumns.zip (144.2 KB):

Is there any recommendation on how to best do Step 2?

Many thanks in advance for your support,
Isabell

Hi,
you can use the math formula node for any mathematical expression.
//edit: Sorry, I misread that you need the column n-5. Let me think about that for a second…
Kind regards
Alexander

Hi again,
Could you use a column list loop start and then build the expression for the math formula node dynamically using a string manipulation node? The expression could then be passed to the math formula node using a flow variable. It’s not pretty, but should work ok.
Kind regards
Alexander

To reference column by number you can use Column Expression node.

1 Like

Hi Alexander,
Many thanks for your proposed solution. Unfortunately, I am not 100% sure how to implement what you’ve suggested. Could you do me the favor and re-explain/attach a workflow based on the one I’ve uploaded?
Thank you very much in advance and best regards,
Isabel

Hey,
@izaychik63 had a really good suggestion with the column expression. I have created a small example workflow that demonstrate how it could be done. Please see attached workflow. Feel free to ask if you have any questions about it. It consists of a counting loop that loops through your columns. The column expression node uses the flow variable for the current iteration to access columns by index and calculates the difference between the columns at index “currentIteration + 1” and “currentIteration”. Then there are some nodes to create the names of the new columns and that’s it.
Kind regards
Alexander
ColumnNum.knwf (23.9 KB)

7 Likes

Hey Alexander,

1000 thanks for your thorough help and especially the example - highly appreciated. It’s a great solution & works perfectly.

Cheers,
Isabell

2 Likes

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