Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi!
I have two fields (Field1 & Field2) and I'd need to create a new field (Result) including all possible combinations of values in Field1 & Field2:
Field1 | Field2 |
1 | A |
2 | B |
3 | C |
Result |
1-A |
2-A |
3-A |
1-B |
2-B |
3-B |
1-C |
2-C |
3-C |
Any idea how to create Result field?
Thank you so much!
Try something like this :
CartesianProduct:
LOAD Field1 FROM Source;
JOIN (CartesianProduct) Field2 FROM Source;
Final:
LOAD Field1, Field2, Field1 &' - '&Field2 as Result
RESIDENT CartesianProduct;
DROP TABLE CartesianProduct;
Creating all possible combinations can generate a large number of rows, impacting performance and usability. Consider alternative approaches based on the number of combinations and desired functionality.
It's important to provide more context about your dataset size, the number of unique values in each field, and your desired use case for the "Result" field to suggest the most suitable approach. Feel free to share more details for further assistance.
Try something like this :
CartesianProduct:
LOAD Field1 FROM Source;
JOIN (CartesianProduct) Field2 FROM Source;
Final:
LOAD Field1, Field2, Field1 &' - '&Field2 as Result
RESIDENT CartesianProduct;
DROP TABLE CartesianProduct;