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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Anyone know how to parse a text and store in a new column

Hi, I have been trying to find out the best way of parsing out the mfg lot from a group of serial numbers. Four consecutive numbers (Place values are 7-10, As shown below)

 

Mobartle_0-1621886394558.png

First two place are for the week and the second two the year. Can anyone show me how to accomplish this? A Dax calculation? Something?

1 ACCEPTED SOLUTION
KNP
Super User
Super User

Hi @Anonymousl, 

 

This should do the trick...

let
  Source = Table.FromRows(
    Json.Document(
      Binary.Decompress(
        Binary.FromText("i45WMjAyNjXyMDUwNPcwMDC1MFaKjQUA", BinaryEncoding.Base64), 
        Compression.Deflate
      )
    ), 
    let
      _t = ((type nullable text) meta [Serialized.Text = true])
    in
      type table [Column1 = _t]
  ), 
  #"Changed Type" = Table.TransformColumnTypes(Source, {{"Column1", type text}}), 
  #"Inserted Text Range" = Table.AddColumn(
    #"Changed Type", 
    "Text Range", 
    each Text.Middle([Column1], 6, 4), 
    type text
  )
in
  #"Inserted Text Range"

The key is the Text.Middle

 

Hope this helps.

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

This calculated column formula should work

=mid(Data[text],7,4)


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
KNP
Super User
Super User

Hi @Anonymousl, 

 

This should do the trick...

let
  Source = Table.FromRows(
    Json.Document(
      Binary.Decompress(
        Binary.FromText("i45WMjAyNjXyMDUwNPcwMDC1MFaKjQUA", BinaryEncoding.Base64), 
        Compression.Deflate
      )
    ), 
    let
      _t = ((type nullable text) meta [Serialized.Text = true])
    in
      type table [Column1 = _t]
  ), 
  #"Changed Type" = Table.TransformColumnTypes(Source, {{"Column1", type text}}), 
  #"Inserted Text Range" = Table.AddColumn(
    #"Changed Type", 
    "Text Range", 
    each Text.Middle([Column1], 6, 4), 
    type text
  )
in
  #"Inserted Text Range"

The key is the Text.Middle

 

Hope this helps.

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x
Anonymous
Not applicable

Thank you! It worked perfect!!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors