Forum Discussion
RMF40
Oct 01, 2024Copper Contributor
How do I change a table with 2 columns where I have repeating values in both columns into a matrix?
Hopefully I will be able to explain my problem correctly. I have a table with two columns in it. Column A has students in it, column B has the subject that each student is taking. Both column A a...
SergeiBaklan
Oct 01, 2024MVP
As variant that could be Power Query
let
Source = Excel.CurrentWorkbook(){[Name="Students"]}[Content],
GroupNames = Table.Group(
Source, {"Name"},
{
{"Subject", each List.Sort( [Subject] )}
}),
SubjectNames = List.Transform(
{1..List.Max( Table.TransformColumns(
GroupNames,
{"Subject", (q) => List.Count(q)} )[Subject] )},
(e) => "Subject " & Character.FromNumber(e+64)
),
ExtractSubjects = Table.TransformColumns(
GroupNames,
{"Subject", each Text.Combine(List.Transform(_, Text.From), ","), type text}
),
SplitSubjects = Table.SplitColumn(
ExtractSubjects,
"Subject",
Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), SubjectNames)
in
SplitSubjects
Please check attached.