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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

How to split a column based on values

I am looking to split a column, (pictured below) but I only need to split certain values in the column. 
Column to be splitColumn to be split
If the value starts with 1 I would like a split at the space, But values that do not start with 1 I would like to retain the value. 


Example Current State

Resources
1DP01-01 - Operator 1
Battery Lines


Example Desired State

ResourcesResoucres Split
1DP01-01- Operator 1
Battery LinesBattery Lines


Thanks!

 

2 REPLIES 2
AlB
Community Champion
Community Champion

Hi @Anonymous 

Best in the Query Editor. Place the following M code in a blank query to see the steps.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMnQJMDDUNTBU0FXwL0gtSizJL1IwVIrViVZySiwpSS2qVPDJzEstVoqNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Resources = _t]),
    auxT1_ = Table.SelectRows(Source, each Text.Start([Resources],1) = "1"),
    auxT2_ = Table.SelectRows(Source, each Text.Start([Resources],1) <> "1"),
    res1_ = Table.SplitColumn(auxT1_, "Resources", Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, false), {"Resources1", "Resources2"}),
    #"Added Custom" = Table.AddColumn(auxT2_, "Resources2", each [Resources]),
    res2_ = Table.RenameColumns(#"Added Custom",{{"Resources", "Resources1"}}),
    res_ = Table.Combine({res1_, res2_}) 
    
 in
    res_

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

amitchandak
Super User
Super User

@Anonymous , I you may have to use two-three steps in power bi.

Split into column based on last occurrence -

you will get Column 1, column 2

 

column 3 = if [column2] = null then [column1]  else [column2]

 

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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