Using Flow Variables as Column References in Rule Based Filter

HI, I'm using a loop on a table of fieldnames which I want to pass to a rule based filter for the purpose of range checking.

So the expression I have is as follows

$${Sdataitem_fieldname}$$ > $${DDataItem_Range_L}$$ AND $${Sdataitem_fieldname}$$ < $${DDataItem_Range_H}$$ => TRUE

So all the elements are flow variables. If I replace the dataitem_fieldname FV with the actual column name then it works fine. So I suppose that it is something to do with the way that item is used in referencing the incoming data set.

Is there a way to do this in a Rule Filter or does it require resorting to Java snippet (for example) ?

Kind regards

 

Steve T

You cannot dynamically set column names via flow variables. You can only use flow variables as values or control the whole rules section via a single flow variable.

I let Gabor to comment if it may be possible to extend the rule engine dynamic column references.

OK, I suspected that would be the case. But wat do you mean when you say '..or control the whole rule section via a single flow variable' ? I can construct something like -

$RUWHEID_RA$ > $${DDataItem_Range_L}$$ AND $RUWHEID_RA$ < $${DDataItem_Range_H}$$ => TRUE

...and store it in a flow variable but including this $$this.varaible$$ on its own as an expression generates error ' Invalid settings, line 1, col 17, expected an operator'. If I miss out the ' => TRUE'  and add this after the variable name in the expression then error is 'Invalid settings: Expected a relation to complete condition but got =>'

If I cut and paste the expression above then the node works fine.

Probably I have misunderstood and an alternative approach is needed but would be grateful if you could clarify.

Thanks for your swift response

 

Steve

 

Hi Steve,

I suggest using a Java Snippet with its getCell() methods. It can't filter, and the Java Snippet Row Filter doesn't have that method, but you can add an extra column this way. Then use this new column to filter with some other node.

Thanks for the hint, I'm not familiar with java and was hoping to avoid but I guess I'll have to roll my sleeves up.... The Math Formula Node and the String Manipulation node should get to gether sometime; their offspring might just be up to the job ! : )

By way of update, after a bit of trawling through the Forum I found someone who had had a similar issue wheredynamic access to a column whose name was represented in a flow variable was required. He also was struggling with resolving via a Java snippet.

I adapted the solution to use a column merger node to produce a new column with a generic name (e.g. temp) and then use that in the subsequent rule based row filter. For setting of the Primary and Secondary column names in the node, I just entered the same flow variable (containing the name) for both. A bit inefficient but can drop the temp variable shortly afterwards.

Steve T

It is not possible to extend its functionality this way (if you mean by an extension point), though it might be changed -like adding an option to recursively interpret the rules after flow variable expansion. Though I think it might be confusing, and better create flow variables for the -fixed number- rules and set them as rules. (Or use Java Snippet Row Filter as Marlin suggested.)

Cheers, gabor