The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here
[SOLVED]How to transpose/de-pivot a Utility Matrix
How do I turn a matrix such as this one:
into a new transposed one that looks like this:
Thank you. Apologies if this has been asked before, but my search couldn't bring the results I was looking for.
Customer ID | Product1 | Product2 | Product3 | Product4 | |
1 | 1 | 0 | 3 | 0 | 1 |
2 | 0 | 1 | 2 | 0 | 1 |
3 | 1 | 0 | 0 | 0 | 4 |
into a new transposed one that looks like this:
CustomerID | ProductID | Qty |
1 | Product1 | 1 |
1 | Product2 | 0 |
1 | Product3 | 3 |
1 | Product4 | 0 |
1 | Product5 | 1 |
2 | Product1 | 0 |
2 | Product2 | 1 |
2 | Product3 | 2 |
2 | Product4 | 0 |
2 | Product5 | 1 |
3 | Product1 | 1 |
3 | Product2 | 0 |
3 | Product3 | 0 |
3 | Product4 | 0 |
3 | Product5 | 4 |
Tagged:
0
Answers
~Martin
Dortmund, Germany
Yes thanks I did look at De-Pivot and as far as I can see, it is failing to turn each column name/attribute name into a row instance. I have mucked around with transpose as well with no success. May I also add that in my real data set the product attributes range from Product1....Product1001.
Regards,
Chiko
Have a look at this process. looks like it does what you like to have.
Dortmund, Germany
In short where you are prefixing the serial with Product_ in the above process is where I am getting stuck, I simply need to read the column header(SKU) as it is, rather than generate a serial and then use regular expressions. In my case, I must take the column names verbatim.
Regards,
Chiko
That should work:
Dortmund, Germany
You are a genius! The mapping table worked a treat.
Regards,
Chiko