Combining multiple rows into single row

Hi @Thyme ,

Yes, you are right that we have 30 unique tests from the “Grouping of tests and 42 total. Yeah your initial solution can work but in that case we need to use normal strings instead if test1,test2 - if you can guide me how to use normal strings instead of test1,test2 … and cart1, cart2… we can use that logic.

or
else we can use below logic as well

-if the array contains “kiwi”- then instead of checking all the values for fruits group , we can say that “fruit” groups is possible
-and if the array contains “garlic”- then instead of checking all the values for vegetable group , we can say that “vegetable” groups is possible
-and if the array contains “dark”- then instead of checking all the values for chocolate group , we can say that “chocolate” groups is possible

  • and if the array contains “cheese”- then instead of checking all the values for butter group , we can say that “butter” groups is possible
    -and if the array contains “grape”,“banana” but not “kiwi”, we can say that “sugar” groups is possible
    -and if the array contains “apple”,“mango”,“grape”,“berry” but not “kiwi”- , we can say that “cottage” groups is possible
  • and if the array contains “berry”,but not “grape”,“apple”- , we can say that “berries” groups is possible
    -and if the array contains “apple”,“mango” but not “grape”- , we can say that “apples” groups is possible
    -and if the array contains “potato” and “apple”- then we can say that “apple-pie#” groups is possible
    -and if the array contains “butterscotch” then we can say that “vegetable” groups is possible

but I am not sure how to put the above logic into Java code, if you can help me to convert above logic into Java snippet , that should also work

Thanks in advance.

And how does the input data look before the self joins?

Input data before self joins is with same data like product ids with different test with lot more few columns so self join is done to get all the columns with one row of for each product id with array of tests.

I think I could turn this into a no-code solution if the Reference Row Filter would support bitwise comparisons (I’m asking too much here, I know that :innocent:)

Anyway, I generalised the solution, there’s no hardcoding now. The configuration is done via a Table Creator instead.
Using that, the input names are mapped onto powers of 2 to get the input into numerical format. That means the input information is already encoded bitwise.
Same is applied to group definition. It’s passed as string Flow Variable, because long int Flow Variables are not supported by the Java Snippet node.
The rest is basically the same as before.

Tests that are not covered by any fitting group will be in a separate column. They can still be processed to catch input errors, just take the table directly after the Java Snippet and do the same Cell Splitter, Ungroup, Joiner combo. Just make sure you join with unique tests instead.

Warning: This works for up to 63 unique tests and up to 63 unique groups. More than that and the variables will overflow. I didn’t check what happens in that case (and the code doesn’t either!).
Also, there can’t be any duplicate tests in the input. Just use a Duplicate Row Filter if you can’t trust the input.


carts.knwf (205.0 KB)

Hey @analytics_sharma,

just wanted to ask if that works for you? :slight_smile: