Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe'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
Seeking for kind help in respect a problem which I have, I have next table, which contains two columns, one with comma separated values:
| Name | | Country |
| Maria | | Spain, Portugal, Italy |
| Pedro | | Spain, Italy |
| Jose | | France, Germany, Italy |
| Carlos | | Germany, Spain |
| Ana | | Spain, Portugal, Italy, France, Germany |
I need to find a way how to convert this so that each comma separed value in column Country comes to a own row and Name will repeat for each matching case, so like below:
| Name | | Country |
| Maria | | Spain |
| Maria | | Portugal |
| Maria | | Italy |
| Jose | | France |
| Jose | | Germany |
| Jose | | Italy |
| Carlos | | Germany |
| Carlos | | Spain |
| Ana | | Spain |
| Ana | | Portugal |
| Ana | | Italy |
| Ana | | France |
| Ana | | Germany |
Thank you for your help!
Solved! Go to Solution.
You can add a new column using the Text.Split function as in the example:
=Text.Split([Country], ",")
A new column of type List will be created. Then just expand it.
You can add a new column using the Text.Split function as in the example:
=Text.Split([Country], ",")
A new column of type List will be created. Then just expand it.
See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8k0sykxU0lEKLkjMzNNRCMgvKilNT8zRUfAsScypVIrViVYKSE0pykcoQUh45RenAsXdihLzklN1FNxTi3IT8yqRVTgnFuXkFwPVwOXAhoDlHPNw26ujgGaoUmwsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, Country = _t]),
Custom1 = Table.ReplaceValue(Source,each [Country],each Text.Split([Country],", "),Replacer.ReplaceValue,{"Country"}),
#"Expanded Country" = Table.ExpandListColumn(Custom1, "Country")
in
#"Expanded Country"
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 | |
| 4 | |
| 3 | |
| 2 | |
| 2 |
| User | Count |
|---|---|
| 8 | |
| 7 | |
| 6 | |
| 6 | |
| 5 |