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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
witbi
Helper I
Helper I

Calculated column with comma delimited text split into rows in a new table

I have a calculated column called 'Tasks' in 'Table1' that is delimited by commas which I would like to split into separate rows in a new table called 'Table2'. As 'Tasks' is a calculated column I am not able to use split column in Power Query, in any case I would like a separate table.

Any help most appreciated. Many thanks

 

Table1

Id Event            Names                 Tasks

1  Halloween    Bob, Kate             invitations, emails, catering

2  Christmas     Kate, Pete, Tom   invitations, catering, decorations, carols, 

Table2

Id Event            Names                 Tasks

1  Halloween    Bob, Kate             invitations
1  Halloween    Bob, Kate             emails
1  Halloween    Bob, Kate             catering

2  Christmas     Kate, Pete, Tom   invitations
2  Christmas     Kate, Pete, Tom   catering
2  Christmas     Kate, Pete, Tom   decorations
2  Christmas     Kate, Pete, Tom   carols

1 ACCEPTED SOLUTION
AntrikshSharma
Super User
Super User

@witbi Try this, also PBI file is attached below my signature:

1.PNG

Table =
VAR WordCount =
    ADDCOLUMNS (
        witbi,
        "@Word Count",
            LEN ( witbi[Tasks] ) - LEN ( SUBSTITUTE ( witbi[Tasks], ",", "" ) ) + 1
    )
VAR MaxWordCount =
    MAXX ( WordCount, [@Word Count] )
VAR TempTable =
    FILTER (
        GENERATE ( WordCount, GENERATESERIES ( 1, MaxWordCount, 1 ) ),
        [Value] <= [@Word Count]
    )
VAR SplitTextByNumber =
    ADDCOLUMNS (
        TempTable,
        "Final String", TRIM ( PATHITEM ( SUBSTITUTE ( witbi[Tasks], ",", "|" ), [Value] ) )
    )
VAR Result =
    SELECTCOLUMNS (
        SplitTextByNumber,
        "ID", [ID],
        "Event", [Event],
        "Tasks", [Final String]
    )
RETURN
    Result

View solution in original post

5 REPLIES 5
AntrikshSharma
Super User
Super User

@witbi  You're welcome!

AntrikshSharma
Super User
Super User

@witbi Try this, also PBI file is attached below my signature:

1.PNG

Table =
VAR WordCount =
    ADDCOLUMNS (
        witbi,
        "@Word Count",
            LEN ( witbi[Tasks] ) - LEN ( SUBSTITUTE ( witbi[Tasks], ",", "" ) ) + 1
    )
VAR MaxWordCount =
    MAXX ( WordCount, [@Word Count] )
VAR TempTable =
    FILTER (
        GENERATE ( WordCount, GENERATESERIES ( 1, MaxWordCount, 1 ) ),
        [Value] <= [@Word Count]
    )
VAR SplitTextByNumber =
    ADDCOLUMNS (
        TempTable,
        "Final String", TRIM ( PATHITEM ( SUBSTITUTE ( witbi[Tasks], ",", "|" ), [Value] ) )
    )
VAR Result =
    SELECTCOLUMNS (
        SplitTextByNumber,
        "ID", [ID],
        "Event", [Event],
        "Tasks", [Final String]
    )
RETURN
    Result

Many thanks Antriksh. Appreciate the quick reply and sample. This does what I was looking for! 

kumar27
Advocate V
Advocate V

You can use Split comma by delimeter to split the values into separate rows.

 

Click Edit queries to open Power Query Editor, select the column you want to split and click Split Column -> By Delimeter: Make sure the delimiter is correct, and Rows is selected in Split into:Capture.JPG

 

Thanks kumar27

 

I am familiar with the Power Query split column function, however as the table column is calculated this doesn't seem to be a solution I can use. Any other thoughts?

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.