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, I am trying Pivot and I get errors instead of names in two rows. please let me know what am i doing wrong? thank you.
I want to acheive something like this -
| USA | India | England | Brazil |
| Nick | Bala | Kate | Pele |
| Pulisik | Virat | Mount | Kaka |
Solved! Go to Solution.
Hi,
This M code works
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8stMzlbSUQoNdlSK1YlWckrMSQRyPfNSMhPBAt6JJalAAde89JzEvBSwkG9+aV4JmlhAaU5mcSaySQGpOSCNTkWJVZk5UKOyE1FFwjKLEksQ1sUCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Sales man" = _t, Country = _t]),
Partition = Table.Group(Source, {"Country"}, {{"Partition", each Table.AddIndexColumn(_, "Index",1,1), type table}}),
#"Expanded Partition" = Table.ExpandTableColumn(Partition, "Partition", {"Sales man", "Index"}, {"Sales man", "Index"}),
#"Pivoted Column" = Table.Pivot(#"Expanded Partition", List.Distinct(#"Expanded Partition"[Country]), "Country", "Sales man"),
#"Removed Columns" = Table.RemoveColumns(#"Pivoted Column",{"Index"})
in
#"Removed Columns"
Hope this helps.
Hi,
Before creating a Pivot, you should assign occurence numbers to Countries in another column, say Index. The first occurence of each country should show 1 and successive enries of that country should show 2,3 etc. This can be done in the Query Editor. Share data in a format that can be pasted in an MS Excel worksheet.
I have added the index and done pivoting and I get something like this with nulls -
How can I acheive something like this -
| USA | India | England | Brazil |
| Nick | Bala | Kate | Pele |
| Pulisik | Virat | Mount | Kaka |
As requested in my previous measage, "Share data in a format that can be pasted in an MS Excel worksheet."
@Ashish_Mathur here is the data, please help.
| Sales man | Country |
| Nick | USA |
| Bala | India |
| Kate | England |
| Mount | England |
| Pulisik | USA |
| Pele | Brazil |
| Kaka | Brazil |
| Virat | India |
Hi,
This M code works
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8stMzlbSUQoNdlSK1YlWckrMSQRyPfNSMhPBAt6JJalAAde89JzEvBSwkG9+aV4JmlhAaU5mcSaySQGpOSCNTkWJVZk5UKOyE1FFwjKLEksQ1sUCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Sales man" = _t, Country = _t]),
Partition = Table.Group(Source, {"Country"}, {{"Partition", each Table.AddIndexColumn(_, "Index",1,1), type table}}),
#"Expanded Partition" = Table.ExpandTableColumn(Partition, "Partition", {"Sales man", "Index"}, {"Sales man", "Index"}),
#"Pivoted Column" = Table.Pivot(#"Expanded Partition", List.Distinct(#"Expanded Partition"[Country]), "Country", "Sales man"),
#"Removed Columns" = Table.RemoveColumns(#"Pivoted Column",{"Index"})
in
#"Removed Columns"
Hope this helps.
@Ashish_Mathur It worked perfectly fine, but can you please explain me the m code? thanks.
You are welcome. Step through each step in the Applied steps section of the QUery Editor to understand what is happening.
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 |
|---|---|
| 57 | |
| 38 | |
| 33 | |
| 19 | |
| 16 |
| User | Count |
|---|---|
| 68 | |
| 66 | |
| 41 | |
| 34 | |
| 24 |