Forum Discussion
Unpivot several columns with attribute and value
- 2 years ago
i take these example
ok problem solve follow below step
1. select ID Articolo and unpivote other column
2. replace value code mat1, code mat2, code mat3, code amt4 to code
and qt mat1, qt amt2, qt amt3, qt mat4 to qt
3. add conditional column like these
which look like these
4. add another conditional column like these
5. copy qt column and paste to new table(qt table) and add index column which look like below
6. now return to original table and add index to original table
7. now merge original table and qt tqble
8. now expand table click on rounded(red) area
by clicking red area open interface and from that unselect index column
press ok which look like these
9. change qt table name to qt and select Id Articolo, code and qt and remove other column and it look like these
10. now filter table and which show those value non-null value
and it look like these
here solution done
don't get confuse with values because i take some different value from you but following my step you got your answer here t attach step screenshort for comfortness
close and apply from home tab and paly with it
Did i answer your question? Mark my post as a solution which help other people to find fast and easily.
To unpivot your table and transform it into the desired format with three columns (Code Article, Code of Material, and Quantity), you can use Power Query in Power BI. Here's a step-by-step guide:
Assuming your original table looks something like this:
| Code Article | Code Material1 | Quantity1 | Code Material2 | Quantity2 | ... |
|--------------|----------------|-----------|----------------|-----------|-----|
| A001 | M001 | 10 | M002 | 5 | ... |
| B002 | M003 | 15 | M004 | 8 | ... |
Follow these steps to unpivot your table:
1. Open your Power BI report.
2. Load your table into Power Query:
- In Power BI Desktop, go to the "Home" tab.
- Click on "Edit Queries" to open the Power Query Editor.
3. Select the columns that you want to unpivot (e.g., "Code Material1," "Quantity1," "Code Material2," "Quantity2," etc.).
4. Go to the "Transform" tab in the Power Query Editor.
5. Click on "Unpivot Columns" in the "Transform" tab. This will transform your selected columns into rows, creating new columns "Attribute" and "Value."
6. Rename the "Attribute" column to "Code Type" (or any other suitable name) and the "Value" column to "Code" (or "Quantity" if appropriate).
7. Close and apply the changes to load the transformed table back into Power BI.
Now, your table should be in the desired format with three columns: "Code Article," "Code Type" (which indicates whether it's a material code or a quantity code), and "Code" (which contains the respective material code or quantity).
Here's how the transformed table would look:
| Code Article | Code Type | Code |
|--------------|-----------|-------|
| A001 | Material | M001 |
| A001 | Quantity | 10 |
| A001 | Material | M002 |
| A001 | Quantity | 5 |
| B002 | Material | M003 |
| B002 | Quantity | 15 |
| B002 | Material | M004 |
| B002 | Quantity | 8 |
You can now use this transformed table in your Power BI report for further analysis and visualization.
Anyone can help me ?