Forum Discussion
Data Transformation for Excel with two (or more) headers
- 6 years ago
Hello 🙂
You can do it easily by following below steps:
1. Get data from that Excel file and copy the query:
2. In the second query keep the top two rows only
3. Transpose the table
4. Fill down and remove empty and rename columns if needed
5. Go back to the first table and remove first row and promote header and rename needed colums and fill the year
6. Unpivot Table
7. Merge & Expand query
Hope thats answers your question.
Please don't hesitate to contact me for further support.
Best wishes 🙂
----------------------------------------------
Did I answer your question? Mark my post as a solution!
Hello 🙂
You can do it easily by following below steps:
1. Get data from that Excel file and copy the query:
2. In the second query keep the top two rows only
3. Transpose the table
4. Fill down and remove empty and rename columns if needed
5. Go back to the first table and remove first row and promote header and rename needed colums and fill the year
6. Unpivot Table
7. Merge & Expand query
Hope thats answers your question.
Please don't hesitate to contact me for further support.
Best wishes 🙂
----------------------------------------------
Did I answer your question? Mark my post as a solution!
Motasem_Yakhola thanks a lot. I managed to tackle the issue based on your idea and note what I made it step-by-step as below.
1. Load Excel table into Power BI
2. Duplicate the table
3. Remove "promoted headers" and "change type" (you can also use "Use Header as First Row")
Result:
4. Remove the first two columns and all rows except the top 2 rows. Then, select all and click "transpose".
Result:
5. Select column 1 and "Fill" -> "Down"
Result:
6. Start to deal with the original table. Only keep the first two steps in "APPLIED STEPS" and make the table looks like below
7. Remove the first row and make the second row the headers
8. Select the first two columns and click "Unpivot Columns" -> "Unpivot Other Columns"
Result:
9. Merge this original table and the table we duplicated earlier
10. Use product name as keys to merge those two tables. Choose "Left Outer Join"
Result:
11. Select the two arrows icon on the right corner of "Sheet2(2)" column. Then, unselect column 2 (product name) and only select column1 because column 1 has the information we need.
Result:
12. Use "Fill"->"Down" to deal with all blanks in the first column. Change all column names. Done!