Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hey guys,
i have a Excel File, which is used by the sales team to map leads/upcoming project to internal project roles, which are needed in the upcoming projects. The sales team useses "x" in the column of the project role, if this role is needed in the possible project. My goal ist to transform all marked ("x") roles into a column.
Leads | Role1 | Role2 | Role3 | Role4 |
L1 | x | x | x | |
L2 | x | |||
L3 | x | x |
Leads | Roles needed |
L1 | Role1, Role2, Role3 |
L2 | Role4 |
L3 | Role1, Role2 |
Thank you for your help! 😉
Solved! Go to Solution.
Hi @Anonymous ,
You can create a new blank query and paste the whole M syntax in the Advanced Editor :
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8jFU0lGqQMIKSrE6QGEjMBOBKyDCxigqwapjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Leads = _t, Role1 = _t, Role2 = _t, Role3 = _t, Role4 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Leads", type text}, {"Role1", type text}, {"Role2", type text}, {"Role3", type text}, {"Role4", type text}}),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Leads"}, "Attribute", "Value"),
#"Filtered Rows" =Table.SelectColumns( Table.SelectRows(#"Unpivoted Other Columns", each ([Value] = "x")), {"Leads","Attribute" }),
#"Grouped Rows" = Table.Group(#"Filtered Rows", {"Leads"}, {{"Roles Needed", each Text.Combine([Attribute],", ") ,type text}})
in
#"Grouped Rows"
Output:
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
You can create a new blank query and paste the whole M syntax in the Advanced Editor :
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8jFU0lGqQMIKSrE6QGEjMBOBKyDCxigqwapjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Leads = _t, Role1 = _t, Role2 = _t, Role3 = _t, Role4 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Leads", type text}, {"Role1", type text}, {"Role2", type text}, {"Role3", type text}, {"Role4", type text}}),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Leads"}, "Attribute", "Value"),
#"Filtered Rows" =Table.SelectColumns( Table.SelectRows(#"Unpivoted Other Columns", each ([Value] = "x")), {"Leads","Attribute" }),
#"Grouped Rows" = Table.Group(#"Filtered Rows", {"Leads"}, {{"Roles Needed", each Text.Combine([Attribute],", ") ,type text}})
in
#"Grouped Rows"
Output:
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.