Forum Discussion

Syndicate_Admin's avatar
Syndicate_Admin
Administrator
3 years ago
Solved

Split rows into columns without delimiter

Hello group!

I have a column (Information) that I import from an excel file where 3 data are displayed as follows:

InformationValue
Familia1500
SubFamilia1300
Producto150
Producto2250
SubFamilia2200
Producto3200
Familia2500
SubFamilia3300
Producto4300
SubFamilia4200
Producto5100
Producto6100

And I want to transform it into 3 separate columns:

FamilySubfamilyProductValue
Familia1SubFamilia1Producto150
Familia1SubFamilia1Producto2250
Familia1SubFamilia2Producto3200
Familia2SubFamilia3Producto4300
Familia2SubFamilia4Producto5100
Familia2SubFamilia4Producto6100

How can I do this transformation in Power Query?

Thanks a lot.

  • Hi Syndicate_Admin,

     

    You can use Power Query to transform the data from the single column to multiple columns. Here's how:

    1. Open Power BI and create a new query by clicking on "Get Data" in the Home tab.

    2. Select the Excel file containing the data and click on "Transform Data".

    3. In the Power Query Editor, select the "Information" column and click on "Split Column" in the "Transform" tab.

    4. Choose "By Delimiter" and enter the delimiter as a Tab character (\t).

    5. Choose "Split into Rows" and click OK.

    6. Now you should have a new column with the separate values. Rename the column to "Category" by right-clicking on the column header and choosing "Rename".

    7. Create a new column by clicking on "Add Column" in the "Add Column" tab.

    8. Enter the following formula in the formula bar:

    = if Text.StartsWith([Category], "Familia") then [Category] else null

    1. Name the new column "Family".

    2. Create another new column and enter the following formula:

    = if Text.StartsWith([Category], "SubFamilia") then [Category] else null

    1. Name the new column "Subfamily".

    2. Create a third new column and enter the following formula:

    = if Text.StartsWith([Category], "Producto") then [Category] else null

    1. Name the new column "Product".

    2. Delete the "Category" column by right-clicking on the column header and choosing "Remove".

    3. Select all the columns (Family, Subfamily, Product, and Value) by clicking on the first column header and holding down the Shift key while clicking on the last column header.

    4. Click on "Remove Other Columns" in the "Home" tab.

    5. Close and apply the changes by clicking on "Close & Apply" in the "Home" tab.

    Your data should now be transformed into the desired format with separate columns for Family, Subfamily, Product, and Value.

     

    Best regards, 

    Isaac Chavarria 


    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

2 Replies

  • ichavarria's avatar
    ichavarria
    Solution Specialist

    Hi Syndicate_Admin,

     

    You can use Power Query to transform the data from the single column to multiple columns. Here's how:

    1. Open Power BI and create a new query by clicking on "Get Data" in the Home tab.

    2. Select the Excel file containing the data and click on "Transform Data".

    3. In the Power Query Editor, select the "Information" column and click on "Split Column" in the "Transform" tab.

    4. Choose "By Delimiter" and enter the delimiter as a Tab character (\t).

    5. Choose "Split into Rows" and click OK.

    6. Now you should have a new column with the separate values. Rename the column to "Category" by right-clicking on the column header and choosing "Rename".

    7. Create a new column by clicking on "Add Column" in the "Add Column" tab.

    8. Enter the following formula in the formula bar:

    = if Text.StartsWith([Category], "Familia") then [Category] else null

    1. Name the new column "Family".

    2. Create another new column and enter the following formula:

    = if Text.StartsWith([Category], "SubFamilia") then [Category] else null

    1. Name the new column "Subfamily".

    2. Create a third new column and enter the following formula:

    = if Text.StartsWith([Category], "Producto") then [Category] else null

    1. Name the new column "Product".

    2. Delete the "Category" column by right-clicking on the column header and choosing "Remove".

    3. Select all the columns (Family, Subfamily, Product, and Value) by clicking on the first column header and holding down the Shift key while clicking on the last column header.

    4. Click on "Remove Other Columns" in the "Home" tab.

    5. Close and apply the changes by clicking on "Close & Apply" in the "Home" tab.

    Your data should now be transformed into the desired format with separate columns for Family, Subfamily, Product, and Value.

     

    Best regards, 

    Isaac Chavarria 


    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly