Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
How do i create all possible combination (order does not matter) according to category?
sample data:
transport | grab |
transport | uber |
transport | comfort |
bank | dbs |
bank | hsbc |
bank | ocbc |
bank | uob |
food | kfc |
food | macdonald |
food | burger_king |
food | five_fingers |
food | long_john_silver |
desired output:
Category | combination |
transport | grab, uber |
transport | grab, comfort |
transport | uber, comfort |
bank | dbs, hsbc |
bank | dbs, ocbc |
bank | dbs, uob |
bank | hsbc, ocb |
bank | hsbc, uob |
bank | ocbc, uob |
food | kfc, macdonald |
food | kfc, burger_king |
food | kfc, five_fingers |
food | kfc, long_john_silver |
food | macdonald, burger_king |
food | macdonald, five_fingers |
food | macdonald, long_john_silver |
food | burger_king, five_fingers |
food | burger_king, long_john_silver |
food | five_fingers, long_john_silver |
Here you go:
Data:
NoConcatenate Load
*,
AutoNumber(Item) as ItemId
Inline [
Category, Item
transport, grab
transport, uber
transport, comfort
bank, dbs
bank, hsbc
bank, ocbc
bank, uob
food, kfc
food, macdonald
food, burger_king
food, five_fingers
food, long_john_silver
];
Join Load Distinct
Category,
ItemId as ItemId2,
Item as Item2
Resident Data;
Combinations:
NoConcatenate Load
Category,
Item & ', ' & Item2
Resident Data
Where ItemId < ItemId2;
Drop Table Data;
Here you go:
Data:
NoConcatenate Load
*,
AutoNumber(Item) as ItemId
Inline [
Category, Item
transport, grab
transport, uber
transport, comfort
bank, dbs
bank, hsbc
bank, ocbc
bank, uob
food, kfc
food, macdonald
food, burger_king
food, five_fingers
food, long_john_silver
];
Join Load Distinct
Category,
ItemId as ItemId2,
Item as Item2
Resident Data;
Combinations:
NoConcatenate Load
Category,
Item & ', ' & Item2
Resident Data
Where ItemId < ItemId2;
Drop Table Data;
Thanks! your a genius.