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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
Qotsa
Helper V
Helper V

Split column into 2 - Query Editor

Hi,

 

Is it possible in Query Editor to split the below text column into 2.

I'd like 1 column to contain the numbers (highlighted in blue in pic below) & the other column to contain the text (highlighted in red).

text.png

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @Qotsa ,

 

Did you mean extract text value from list? If this is a case, you can try to use following formula:

#"Added Custom" = Table.AddColumn(#"Changed Type", "Number", each try if Number.From([Column1]) <> null then null else [Column1] otherwise [Column1])

Full query:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjI2MTJRitWJVjI0NtIztQAzjY1MjIxDXMHslFSQYCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Number", each try if Number.From([Column1]) <> null then null else [Column1] otherwise [Column1])
in
    #"Added Custom"

12.png


Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

Hi @Qotsa ,

 

Did you mean extract text value from list? If this is a case, you can try to use following formula:

#"Added Custom" = Table.AddColumn(#"Changed Type", "Number", each try if Number.From([Column1]) <> null then null else [Column1] otherwise [Column1])

Full query:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjI2MTJRitWJVjI0NtIztQAzjY1MjIxDXMHslFSQYCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Number", each try if Number.From([Column1]) <> null then null else [Column1] otherwise [Column1])
in
    #"Added Custom"

12.png


Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
AlB
Super User
Super User

Hi @Qotsa 

 

What exactly would your expected result look like?

 

You could add two custom columns, one with the rows with numbers  and nulls elsewhere and another one with the text rows and nulls elsewhere. Something like this. Note 'Column1' is the name of the column in the original table. Update that if required.  

 

let
    Source = PLACE HERE YOUR SOURCE ,
    #"Added Custom" = Table.AddColumn(Source, "Numbers", each if Text.Remove([Column1],{"0".."9", ","})="" then [Column1] else null),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Text", each if Text.Remove([Column1],{"0".."9", ","})<>"" then [Column1] else null),
    #"Changed Type" = Table.TransformColumnTypes(#"Added Custom1",{{"Numbers", type number}, {"Text", type text}})
in
    #"Changed Type"

 

You could remove the original column at the end if you need to.

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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

Users online (2,367)