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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Column with text and numbers

I have a column formated as text with 2 types of data. 1) 12345 and 2) AB123. Now I am looking for a way to have in another column the Values of 1 as values and the first 2 letters of 2 as text. It is needed to make a connection to another table in which the values and the letters are connected to cities.

 

An idea is welcome.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

My solution was:  

to get the value in a new Column:

ProductValue = VALUE(database[column])
and for the first 2 letters
ProductID = LEFT(database[column];2)
 
Very simple but it it does what is needed.
 

View solution in original post

2 REPLIES 2
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

If i understand you correct, you want

column         ->   column1   column2

12345                  12345        AB

AB123

 

If so, in Edit queries,

1. add two column

Capture8.JPG

2.Replace errors with null

3.add conditional column

4.Fill down for "Custom" column

5.Filter Rows which is null for 'Custom.1"

6. remove columns

Capture9.JPG

 

Then Whole code in Advanced editor

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQyNjFVitWJVnJ0ArLBLEMjE1MzMMvZBchWio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [column = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"column", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Number.FromText([column])),
    #"Inserted First Characters" = Table.AddColumn(#"Added Custom", "First Characters", each Text.Start([column], 2), type text),
    #"Replaced Errors" = Table.ReplaceErrorValues(#"Inserted First Characters", {{"Custom", null}}),
    #"Added Conditional Column" = Table.AddColumn(#"Replaced Errors", "Custom.1", each if [Custom] = null then 1 else null),
    #"Filled Down" = Table.FillDown(#"Added Conditional Column",{"Custom"}),
    #"Filtered Rows" = Table.SelectRows(#"Filled Down", each [Custom.1] <> null and [Custom.1] <> ""),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"column", "Custom.1"})
in
    #"Removed Columns"

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

My solution was:  

to get the value in a new Column:

ProductValue = VALUE(database[column])
and for the first 2 letters
ProductID = LEFT(database[column];2)
 
Very simple but it it does what is needed.
 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.