Hello,
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 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.
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 1/0
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.
Thanks bruni29a,
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.