Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi
I have a set of data i need to unpivot in two ways and don't seem to be able to do it. Can someone help me. I do this in SQL currently using AS and UNION but need to tansfer to power query.
Company | Date | Vendor 1 | Vendor 2 | Vendor 3 | Charge Type 1 | Charge Type 2 | Charge Type 3 | Charge 1 | Charge 2 | Charge 3 |
Dell | 2018 | HP | Epson | Cisco | Printers | Camera | Switch | 100 | 200 | 150 |
Dell | 2019 | Microsoft | Epson | HP | Licenses | Camera | Server | 150 | 200 | 350 |
This is how i need one result to look
Company | Date | Vendor | Charge Type | Charge |
Dell | 2018 | HP | Printers | 100 |
Dell | 2018 | Epson | Camera | 200 |
Dell | 2018 | Cisco | Switch | 150 |
Dell | 2019 | Microsoft | Licenses | 150 |
Dell | 2019 | Epson | Camera | 200 |
Dell | 2019 | HP | Server | 350 |
This is how i need the send to look where i concat Vendor and charge types.
Company | Date | Vendor | Charge |
Dell | 2018 | HP-Printers | 100 |
Dell | 2018 | Epson-Camera | 200 |
Dell | 2018 | Cisco-Switch | 150 |
Dell | 2019 | Microsoft-Licenses | 150 |
Dell | 2019 | Epson-Camera | 200 |
Dell | 2019 | HP-Server | 350 |
Please also be aware in your solution that sometimes I need to join Vendor 1 with Charge Type 2
Solved! Go to Solution.
Hi @JamesT23 ,
You can create new Table2.
Table2 =
FILTER(
UNION(
SELECTCOLUMNS('Table1',"Company",[Company],"Date",[Date],"Vendor",[Vendor 1],"Charge Type",[Charge Type 1],"Charge",[Charge 1]),
SELECTCOLUMNS('Table1',"Company",[Company],"Date",[Date],"Vendor",[Vendor 2],"Charge Type",[Charge Type 2],"Charge",[Charge 2]),
SELECTCOLUMNS('Table1',"Company",[Company],"Date",[Date],"Vendor",[Vendor 3],"Charge Type",[Charge Type 3],"Charge",[Charge 3])
),
"Vendor"<>""&&"Charge Type"<>""&&"Charge"<>"")
Then, create column Vendor_Concatenate in Table2.
Vendor_Concatenate = CONCATENATE(Table2[Vendor],Table2[Charge Type])
Here is my test pbix: https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/EdlYsKW-CSJLjxmFNN...
Best Regards,
Amy
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @JamesT23 ,
You can create new Table2.
Table2 =
FILTER(
UNION(
SELECTCOLUMNS('Table1',"Company",[Company],"Date",[Date],"Vendor",[Vendor 1],"Charge Type",[Charge Type 1],"Charge",[Charge 1]),
SELECTCOLUMNS('Table1',"Company",[Company],"Date",[Date],"Vendor",[Vendor 2],"Charge Type",[Charge Type 2],"Charge",[Charge 2]),
SELECTCOLUMNS('Table1',"Company",[Company],"Date",[Date],"Vendor",[Vendor 3],"Charge Type",[Charge Type 3],"Charge",[Charge 3])
),
"Vendor"<>""&&"Charge Type"<>""&&"Charge"<>"")
Then, create column Vendor_Concatenate in Table2.
Vendor_Concatenate = CONCATENATE(Table2[Vendor],Table2[Charge Type])
Here is my test pbix: https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/EdlYsKW-CSJLjxmFNN...
Best Regards,
Amy
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks Amy!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
96 | |
93 | |
82 | |
70 | |
64 |
User | Count |
---|---|
118 | |
106 | |
93 | |
79 | |
72 |