Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
RickL
Frequent Visitor

Split several columns at once into rows

I have a dataset with multiple concatenated fields and I need to split them into rows based on the delimiter (some cases a semicolon, others a comma). 

 

Report format (input)

IDAggregated_EthnicityAggregated_Ethnicity_Group
1New Zealand European/PakehaEuropean
2New Zealand European/Pakeha;New Zealand MaoriEuropean; Maori
3British/Irish;New Zealand European/PakehaEuropean
4Indian;New Zealand European/Pakeha;OtherAsian; European; Other

 

Output I want

IDAggregated_EthnicityAggregated_Ethnicity_Group
1New Zealand European/PakehaEuropean
2New Zealand European/PakehaEuropean
2New Zealand MaoriMaori
3British/IrishEuropean
3New Zealand European/PakehaEuropean
4IndianAsian
4New Zealand European/PakehaEuropean
4OtherOther
1 ACCEPTED SOLUTION
v-yuezhe-msft
Employee
Employee

@RickL,

Add a cutsom column in your table.

if Text.Contains([Aggregated_Ethnicity], ";")=true and  Text.Contains([Aggregated_Ethnicity_Group], ";")=false then [Aggregated_Ethnicity_Group] &";"&[Aggregated_Ethnicity_Group]else [Aggregated_Ethnicity_Group]

1.PNG

Then duplicate your table, and split columns and merge tables. For more details, please review attached PBIX file.
1.PNG2.PNG

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yuezhe-msft
Employee
Employee

@RickL,

Add a cutsom column in your table.

if Text.Contains([Aggregated_Ethnicity], ";")=true and  Text.Contains([Aggregated_Ethnicity_Group], ";")=false then [Aggregated_Ethnicity_Group] &";"&[Aggregated_Ethnicity_Group]else [Aggregated_Ethnicity_Group]

1.PNG

Then duplicate your table, and split columns and merge tables. For more details, please review attached PBIX file.
1.PNG2.PNG

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks Lydia

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.