I need to clean up a report with 45.000 lines of poorly formated sales data, that looks like this:
| Col1 | Col2 | Col3 | Col4 |
|---|---|---|---|
| 00/01 | Week | ProductA | ProductB |
| 00/01 | 1 | 5 | 5 |
| 00/01 | 2 | 5 | 5 |
| 00/02 | Week | ProductA | ProductB |
| 00/02 | 1 | 5 | 5 |
| 00/02 | 2 | 5 | 5 |
| 00/03 | Week | ProductC | ProductB |
| 00/03 | 2 | 5 | 5 |
The Problems:
- We have multiple header lines repeating in inconsistent spacing (as sometimes a sales-week is missing for some stores), so Table.Split in fixed intervals doesnt work
- When a store doesn't list a product it simple is not outputted in the report, so in store 00/03 is the only store with ProductC
I need to unpivot Col3 (and actually all product columns somehow to arrive at proper table I can work with like:
| StoreNo | Week | ProductA | ProductB | ProductC |
|---|---|---|---|---|
| 00/01 | 1 | 5 | 5 | |
| 00/01 | 2 | 5 | 5 | |
| 00/02 | 1 | 5 | 5 | |
| 00/02 | 2 | 5 | 5 | |
| 00/03 | 2 | 5 | 5 |
I looked far and wide, but either don't know enough PowerQuery M and/or don't know how to call this problem to find a proper solutions. Note: The real table has 88 columns like this with various mixed products (about 30 different products all in all)

