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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
ShreyasK
Frequent Visitor

How to split data in which has data is not uniform

I have table like below which has building name or building number in single line. I want to split building name and building number in 2 separate columns but there is no unique delimeter to split the same. 

 

Actual data:

Building Name
Pune (H41)
Chennai (N51)
J24
Bangalore F74

 

Output Result expected after splitting Building Name and Number:

 

Building NameBuilding Number
PuneH41
ChennnaiN51
J24J24
BangaloreF74

 

Please suggest, how can I achieve this output..?

 

1 ACCEPTED SOLUTION

@v-yueyunzh-msft Thank for your response. Somehow I was able to fix this issue in the source file itself.

But Surely, this will help someone in future.

View solution in original post

2 REPLIES 2
v-yueyunzh-msft
Community Support
Community Support

Hi , @ShreyasK 

According to your descrioption, you want to split data in which has data is not uniform.

For your data , It seems that there is a space between each Building Name and Building Number, we can divide it first and then get the corresponding value.

You can create a blank query in Power Query Editor:

vyueyunzhmsft_0-1689305873764.png

And then you can put this M code in the "Advanced Editor" to test :

vyueyunzhmsft_1-1689305919609.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCijNS1XQ8DAx1FSK1YlWcs5IzctLzFTQ8DOFingZmYBpp8S89MSc/KJUBTdzoEgsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Building Name" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Building Name", type text}}),
    Custom1 = Table.SplitColumn(#"Changed Type", "Building Name",(x)=>  Text.Split(x," "),2),
    #"Renamed Columns" = Table.RenameColumns(Custom1,{{"Building Name.1", "Building Name"}, {"Building Name.2", "Building Number"}}),
    #"Added Custom" = Table.AddColumn(#"Renamed Columns", "Custom", each if [Building Number]=null then [Building Name] else [Building Number]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Building Number"}),
    #"Renamed Columns1" = Table.TransformColumns(Table.RenameColumns(#"Removed Columns",{{"Custom", "Building Number"}}),{"Building Number",(x)=> Text.Remove(x,{"(",")"})       })
in
    #"Renamed Columns1"

 

You can update the Source in your side to test if have some special data ?

 

 

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem. (You can also upload you sample .pbix [without sensitive data] to the OneDrive and share with the OneDrive link to me ! )

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

 

@v-yueyunzh-msft Thank for your response. Somehow I was able to fix this issue in the source file itself.

But Surely, this will help someone in future.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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