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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
PakAli
Frequent Visitor

Split text in 2 columns but the info in the columns are related

I am out of idea, hence seeking the wisdom from the expert

 

Got a table look like this

IDStatusDate
1status1 by userA; status2 by userB; status3 by userCdate1; date2; date3

 

I wanna re arrange it in this format

IDStatusUserDate
1status1userAdate1
1status2userBdate2
1status3userCdate3

 

I have been trying multiple way, but not able to achieve the result that I want
Oh, I can not change the source data format, the output is in that format

 


 

2 ACCEPTED SOLUTIONS
mdaatifraza5556
Super User
Super User

Hi @PakAli 

Can you please try the below M code adjust it in your table.


let
Source = Table.FromRows({
{1, "status1 by userA; status2 by userB; status3 by userC", "date1; date2; date3"}
}, {"ID", "Status", "Date"}),

 

// Split into lists
AddStatusList = Table.AddColumn(Source, "StatusList", each Text.Split([Status], ";")),
AddDateList = Table.AddColumn(AddStatusList, "DateList", each Text.Split([Date], ";")),

 

// Trim spaces
Trimmed = Table.TransformColumns(AddDateList, {{"StatusList", each List.Transform(_, Text.Trim)}, {"DateList", each List.Transform(_, Text.Trim)}}),

 

// Extract Status and User
Parsed = Table.AddColumn(Trimmed, "Combined", each List.Transform(List.Zip({[StatusList], [DateList]}),
each [
Status = Text.BeforeDelimiter(_{0}, "by"),
User = Text.AfterDelimiter(_{0}, "by"),
Date = _{1}
])),

 

// Expand into rows
Expanded = Table.ExpandListColumn(Parsed, "Combined"),
#"Expanded Combined" = Table.ExpandRecordColumn(Expanded, "Combined", {"Status", "User", "Date"}, {"Combined.Status", "Combined.User", "Combined.Date"})
in
#"Expanded Combined"

--------------------------------------------------------------------------------------------------------------------------------

Then expand it.

Screenshot 2025-06-05 092233.png

 

Result

Screenshot 2025-06-05 092253.png

 

 

If this answers your questions, kindly accept it as a solution and give kudos.

View solution in original post

AlienSx
Super User
Super User

let
    Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content], 
    lst = List.TransformMany(
        Table.ToList(Source, (x) => x), 
        (x) => List.Zip({Text.Split(x{1}, "; "), Text.Split(x{2}, "; ")}),
        (x, y) => {x{0}} & y
    ), 
    tbl = Table.FromList(lst, (x) => {x{0}} & Text.Split(x{1}, " by ") & {x{2}}, {"ID", "Status", "User", "Date"})
in
    tbl

View solution in original post

4 REPLIES 4
PakAli
Frequent Visitor

Cool.. it works
I need to study List.Transform + List.Zip
I am blurred, but it works

AlienSx
Super User
Super User

let
    Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content], 
    lst = List.TransformMany(
        Table.ToList(Source, (x) => x), 
        (x) => List.Zip({Text.Split(x{1}, "; "), Text.Split(x{2}, "; ")}),
        (x, y) => {x{0}} & y
    ), 
    tbl = Table.FromList(lst, (x) => {x{0}} & Text.Split(x{1}, " by ") & {x{2}}, {"ID", "Status", "User", "Date"})
in
    tbl

TQVM
your proposal looks elegant,

now sure why Text.Split(x{1}, " |") not working
but changing it to 
Text.Split(x{1}, "|").. it works (maybe " " is not a space, it is specil char

anyway, thanks.. it works

mdaatifraza5556
Super User
Super User

Hi @PakAli 

Can you please try the below M code adjust it in your table.


let
Source = Table.FromRows({
{1, "status1 by userA; status2 by userB; status3 by userC", "date1; date2; date3"}
}, {"ID", "Status", "Date"}),

 

// Split into lists
AddStatusList = Table.AddColumn(Source, "StatusList", each Text.Split([Status], ";")),
AddDateList = Table.AddColumn(AddStatusList, "DateList", each Text.Split([Date], ";")),

 

// Trim spaces
Trimmed = Table.TransformColumns(AddDateList, {{"StatusList", each List.Transform(_, Text.Trim)}, {"DateList", each List.Transform(_, Text.Trim)}}),

 

// Extract Status and User
Parsed = Table.AddColumn(Trimmed, "Combined", each List.Transform(List.Zip({[StatusList], [DateList]}),
each [
Status = Text.BeforeDelimiter(_{0}, "by"),
User = Text.AfterDelimiter(_{0}, "by"),
Date = _{1}
])),

 

// Expand into rows
Expanded = Table.ExpandListColumn(Parsed, "Combined"),
#"Expanded Combined" = Table.ExpandRecordColumn(Expanded, "Combined", {"Status", "User", "Date"}, {"Combined.Status", "Combined.User", "Combined.Date"})
in
#"Expanded Combined"

--------------------------------------------------------------------------------------------------------------------------------

Then expand it.

Screenshot 2025-06-05 092233.png

 

Result

Screenshot 2025-06-05 092253.png

 

 

If this answers your questions, kindly accept it as a solution and give kudos.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.