my doubt is because I can’t do this type of expression in Rule Egine:

A> B - 0.5 AND A <B + 0.5 => TRUE

Rule Engine does not support math operations only logic. You can install Column Expression node to have flexibility and wide range of functionality.

4 Likes

I used column expression but it does not replace the values, making a filter for the expression it builds!

I believe that median function is not working here. You need to calculate median using Math Formula or Group by node.

1 Like

Hi @Ranalytics and welcome to the KNIME forum,

The problem is with using a condition after else. Else does not take any conditions. So “median_plon + 0.5” is the last statement which applies to all cases. Remove the condition for else and you should be fine then.

P.S. If you want to add another condition use “else if”. And use else at the end which then applies to cases where the value is equal to median_plon.

3 Likes

Unfortunately I already used groupby but the knime does not calculate the median, in the image this is the process I did!

it also doesn’t work, I think I’m still writing it wrong, or this data has some problem because the groupby cannot calculate the median,
if the written code is wrong, I ask that you please, if not ask too much, so that you write as it should be written!

I already used alteryx and in it I would just use this code below using the “Filter” tool

[pickup_longitude] >[Median_pickup_longitude]-0.5 AND [pickup_longitude] < [Median_pickup_longitude] + 0.5

You may have missing values. Try the Missing check-mark.

1 Like

I checked and have no missing values, so I got the result using row filter by typing the values by hand, as shown in the image!

Yes, your expression still has a problem. the median() functions takes arguments and calculates the median for that set of values. You are passing a single value to it. If you want to calculate the median of the whole column, use the GroupBy node and pass the median to the Column Expressions node by using the Table Row to Variable node.

1 Like

unfortunately knime is unable to calculate the median using groupby for some reason, as I mentioned in the previous answers

Tarifa de Taxi em Nova York.knwf (47.5 KB)

This is flow if you want to take a look to see if you encounter the problem of not being able to calculate the median by grouoby!

Your workflow does not contain data. Please uncheck “reset workflow” before exporting.

1 Like

This is an example workflow to calculate median in the GroupBy node and then using it in the Column Expressions node:

median_cal_colexp.knwf (114.1 KB)

1 Like
1 Like

The issue is with the “Maximum unique values per group” option in the configuration of the GroupBy node. When aggregating without a group, this number must be equal or greater than the row count.

Actually, I think the more straightforward option here is to use the Math Formula and Col_MEDIAN() function instead. First, use the Math Formula to calculate the median and then you can use the value in the Column Expressions node.

1 Like

thank you very much, I did it for groupby I increased Maximum unique per group!

2 Likes

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