I am a beginner at KNIME. I tried to divide total imp to total user and append new column as Imp U.
I used Math Formula Node and write COL_SUM($Impressions$) / COL_SUM($UserCount$).
I found correct answer but I dont want ImpU column to write every row. I just want to write at first row.
How can I do it?
Thank you for your help
how exactly should it be displayed on the first row?
Should all other rows show the value as missing?
Then you could maybe use the rule engine node to set all other rows to missing
Or you could use the column expression node for more complex logic
Glad you answer me. I may not have explained my problem correctly.
First I sum up Impression column then sum User column. Then sum(impression) / sum(user) and write this conclusion while appending last column.
6.726 is correct answer but I don’t want to show it in every row just want to see on the top row.
I hope I could explain this time
if i understand you correctly then you are looking for the Concat Node
Just rename the columns of you sums to the same names as the original table before the conact so it filles to the same columns
If I want to do it at Excel I want it be like
Hi @JaleS , you can just use this expression in your Math Formula node:
if($$ROWINDEX$$==0, COL_SUM($Impressions$) / COL_SUM($UserCount$), 1/0)
It will put the result only on the first row, and the rest will be left as missing values.
thank you very much for your help.
that solution scares me actually, there are lots of things to learn
No problem @JaleS , happy to help.
There’s nothing to be scared of
I can explain it for you. First off, the if() in the Math Formula. If you click on it from the Function list, it will show you a description:
So, it has 3 elements:
- The condition to evaluate, in our case it’s “
$$ROWINDEX$$==0” (more on this below)
- What value to use if the condition (element #1) is true, in our case, we want what you have as formula, which is “
COL_SUM($Impressions$) / COL_SUM($UserCount$)”
- What value to use if the condition (element #1) is false, in our case, we want a missing value. There’s a trick in Math formula where you do an illegal operation such as a division by 0, it will produce a missing value as it does not know how to evaluate that, so here I used
The variable “
$$ROWINDEX$$” holds the row index of each row, and starts with 0 as the first index.
You can do a quick test on this by simply adding the
$$ROWINDEX$$ as a new column:
So, if we put everything together, it’s saying that if it is the first row (
$$ROWINDEX$$==0), then give the value of
COL_SUM($Impressions$) / COL_SUM($UserCount$), otherwise, that is if
$$ROWINDEX$$==0 is false (meaning it is not the first row), give the value of
1/0 which will return a missing value.
For somebody without any coding or programming experience the above is very helpful and is explained in logical way. Helps in other nodes like column expression also.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.