Using flow variables to set GroupBy grouping columns

I would like to be able to store a list of column names as flow variables (either a single list flow variable, or multiple single value flow variables), and then use those column names for grouping in downstream "GroupBy" nodes.  I would like the setup to be able to handle a variable number of grouping column names. I cannot figure out how to set up the flow variables in the GroupBy node to achieve this.  Any suggestions would be welcome.

Hi,

you need to preconfigure the groupby node for being able to do this. only after the first configuration you can define the flow variables.

You than can use pattern based aggregation page and add a predefined number of rows. Each row can than be controlled from the outside via flow variables.

As it is a regex, you can also construct a regex which will match multiple columns at once.

i hope this helps to get you started!

Cheers, Iris 

Thanks, I'll give it a try.

Hi @Iris,

I come back to this thread as its related.

I have a configuration node/widget in which the user can select multiple columns (the number of columns can go from 1 to 5 for expl). I want to group on these columns in the GroupBy node.
If as preconfigure the node with 5 columns (as you propose), I can find a way with flowvariables to preselect the columns for the grouping. But I will have problems when the user will select different columns and/or less for the grouping.
In brief, I would like to use an array of columns name for the grouping or to indicate a regex of the name of the columns that I want to group.

Any suggestion?
Thanks in advance, Lionel

Hi there @lcollia,

see this topic.

There you will find workflow example how to control variable number of columns in GroupBy node using flow variable type array/collection which is new from version 4.1. Probably you’ll need to modify wf example to your use case.

Br,
Ivan

Hi Ivan,

Thank you for your answer. I will have a look at your solution that is very interesting.

In the meantime I found an other solution that is to filter and conserve the columns on which you want to do the group by, then to merge then in 1 column (a list for expl) [ you can do that because the column merger allow to merge all available columns by the regex]
This unique column will have the same name in all situation, so you can use this merged column for the group by. With a column appender somewhere to keep your original data, the work is done!

Best,
Lionel

2 Likes

Hi Lionel!

Glad you found a way. And it is and interesting one :slight_smile:

Br,
Ivan