We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
Hello Forks,
I have data like this on my power query
| PersonID | Language |
| 184 | Tukrish |
| 184 | English |
| 1255 | Arabic |
| 1255 | English |
| 1255 | Turkish |
and I want to show this data like this
| PersonID | Language1 | Language2 | Language3 |
| 184 | Tukrish | English | |
| 1255 | Arabic | English | Turkish |
If Anyone have any idea please help
Solved! Go to Solution.
Hi @cu-admin, different approach here.
Result
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrQwUdJRCinNLsoszlCK1YGJuOal58BFjExNgUKORYlJmcnIIlgUhZQWZYOFYgE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [PersonID = _t, Language = _t]),
GroupedRows = Table.Group(Source, {"PersonID"}, {{"Count", Table.RowCount}, {"All", each
[ a = Table.Transpose(Table.SelectColumns(_, {"Language"})),
b = List.Transform({ 1..Table.ColumnCount(a) }, (x)=> "Language" & Text.From(x)),
c = List.Zip({ Table.ColumnNames(a), b }),
d = Table.RenameColumns(a, c)
][d], type table}}),
ExpandedAll = Table.RemoveColumns(Table.ExpandTableColumn(GroupedRows, "All", List.Transform({ 1..List.Max(GroupedRows[Count]) }, each "Language" & Text.From(_))), {"Count"})
in
ExpandedAll
Hi, one more solution
let
Source = Your_Source,
GroupedRows = Table.Group(Source, {"PersonID"},
{{"All", each #table(
{"PersonID"} & List.Transform({ 1..Table.RowCount(_)}, each "Language" & Text.From(_)),
{{[PersonID]{0}} & [Language]} )
}}),
Combine = Table.Combine(GroupedRows[All])
in
Combine
Stéphane
Hi @cu-admin, different approach here.
Result
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrQwUdJRCinNLsoszlCK1YGJuOal58BFjExNgUKORYlJmcnIIlgUhZQWZYOFYgE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [PersonID = _t, Language = _t]),
GroupedRows = Table.Group(Source, {"PersonID"}, {{"Count", Table.RowCount}, {"All", each
[ a = Table.Transpose(Table.SelectColumns(_, {"Language"})),
b = List.Transform({ 1..Table.ColumnCount(a) }, (x)=> "Language" & Text.From(x)),
c = List.Zip({ Table.ColumnNames(a), b }),
d = Table.RenameColumns(a, c)
][d], type table}}),
ExpandedAll = Table.RemoveColumns(Table.ExpandTableColumn(GroupedRows, "All", List.Transform({ 1..List.Max(GroupedRows[Count]) }, each "Language" & Text.From(_))), {"Count"})
in
ExpandedAll
Use this code. Replace your source appropriately
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Grouped Rows" = Table.Group(Source, {"PersonID"}, {{"All", each Record.Combine({[PersonID = Table.FirstValue(_)]} & List.Transform({1..Table.RowCount(_)}, (i)=> Record.AddField([], "Language" & Text.From(i), _[Language]{i-1})))}})[[All]],
#"Expanded All" = Table.ExpandRecordColumn(#"Grouped Rows", "All", Record.FieldNames(Record.Combine(#"Grouped Rows"[All])))
in
#"Expanded All"
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 5 | |
| 3 | |
| 3 | |
| 2 | |
| 2 |
| User | Count |
|---|---|
| 11 | |
| 10 | |
| 7 | |
| 7 | |
| 6 |