Help with Merging additional columns based on 2-Cell values

I’m not sure how to setup a project in Easymorph that can achieve what I’m looking to do. It’s best if I describe how my data is stored currently with images and what my output should look like.

I have two tables:
An Item Table - with attributes stored within the cells where the column headers are generic in nature, note there 50 sets of 3 attribute columns:


And a second table that describes the attributes based on the category code that the item is in…and in some cases like the attribute “Type” might have different metadata depending on which category we are talking about:

What I’m trying to do is take the “FILTER_ENABLED” value for the category code - attribute name pair from the second table and add it as a column to the first table.

So output file would have headers like:
Part Number | Category Code | Category Name | Attribute Name 1 | Attribute Value 1 | Attribute UOM 1 | Filter Enabled 1| Attribute Name 2 | Attribute Value 2 | Attribute UOM 2 | Filter Enabled 2| etc etc

Here is a sample file of data if that helps, 2 tabs one for the first table above, one for the second table. Any pointers in the right direction on how to do this is greatly appreciated.

SampleData.xlsx (11.4 KB)

Every time a matrix table needs to be transformed, the idiomatic way is to unpivot it first, transform, and then re-pivot.

In this case, we need to do unpivoting/pivoting two times as the transformation logic requires it. See the example below:

multi-repivot.morph (10.3 KB)

Special thanks for posting a sample dataset. It saved me a lot of time.

Thanks for this - for some reason my brain refuses to fully grasp unpivoting - especially doing it multiple times. :slight_smile:

that said I was trying this on my full dataset and started by unpivoting but received this error - any way to solve this other than to break up my dataset? For now I removed all the other columns from my dataset (that I didn’t put in the sample) and just kept the same columns as shown in the sample data but for attributes 1-50…that seemed to work. I’ll just rejoin that other data back at the end.

Just surprised as I have never seen a row limit error in Easymorph.

Unpivoting multiplies rows, sometimes significantly. If a table has 50 column groups with 3 columns per group, then unpivoting such a table makes it 50 x 3 = 150 times longer, i.e., with 150 times more rows. If your initial dataset had 5 million rows and 150+ columns, unpivoting would create a table with 5 * 150 = 750 million rows - above the current limit of rows per table in EasyMorph (536 million rows). Thus long wide tables sometimes should be unpivoted and processed chunk by chunk, typically using iterations.

No other way to solve it besides breaking up the dataset.

1 Like