Power Query - split to columns by capital letter

pepe74287

New Member
Joined
Feb 4, 2015
Messages
43
Hello,

Another question related to Column split. This time I would need to split data into 2 columns, where delimiter is last capital letter.

For instance:

Robert DuvallCrime
TabuDrama

Should be splitted as:

[table="width: 500"]
[tr]
[td]Column1[/td]
[td]Column2[/td]
[/tr]
[tr]
[td]Robert Duvall[/td]
[td]Crime[/td]
[/tr]
[tr]
[td]Tabu[/td]
[td]Drama[/td]
[/tr]
[/table]

Thanks
Pepe
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Try this code below
Code:
let
    source = Table.FromColumns({ {"Robert DuvallCrime", "TabuDrama"} }, {"text"}),
    AddCol = Table.AddColumn(source, "Custom", each Record.FromList(Splitter.SplitTextByPositions({0,Text.PositionOfAny([text], {"A".."Z"}, 1)}) ([text]), {"Column1", "Column2"})),
    ExpandRecordColumn = Table.ExpandRecordColumn(AddCol, "Custom", {"Column1", "Column2"}, {"Column1", "Column2"}),
    RemoveCol = Table.RemoveColumns(ExpandRecordColumn,{"text"})
in
    RemoveCol

Regards
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,333
Members
452,636
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top