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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Naldi
New Member

How to get and split specific number from value

Hi everyone,

Im new in PBI. I have one column name is "col" with value 9122653911221084122066122. How to I get and split specific number from that column like table below. The specific number is "122". Every number 122 gets 6 characters after that.

 

Naldi_0-1696814737240.png

 

1 ACCEPTED SOLUTION
mussaenda
Super User
Super User

3 REPLIES 3
mussaenda
Super User
Super User

Hi @Naldi ,,

mussaenda_0-1696834742984.png

 

Thank for your help @mussaenda , I appreciate.. 🙂

Royel
Helper III
Helper III

Hi @Naldi 

At first, go to the power query editor. then follow the instructions below 

 

Step 01: Change the Data Type number to text 

Click Add Column and then select Custom Column and pest the code 

= Table.TransformColumnTypes(#"Changed Type",{{"col", type text}})

 Output:

Royel_0-1696831046698.png

 

Step 02: Split first match 

Click Add Column and then select Custom Column and pest the code, then change type to text

= Table.AddColumn(#"Changed Type1", "split_col_1", each if Text.Contains([col], "122") then Text.Middle([col], Text.PositionOf([col], "122"), 6) else null)

 Output: 

Royel_1-1696831244387.png

 

Step 03: Split second match 

Click Add Column and then select Custom Column and pest the code, then change type to text

= Table.AddColumn(#"Changed Type4", "split_col_2", each 
    let
        textToSearch = [col],
        startPos = Text.PositionOf(textToSearch, "122"),
        secondStartPos = if startPos >= 0 then Text.PositionOf(Text.Middle(textToSearch, startPos + 3), "122", Occurrence.First) + startPos + 3 else -1
    in
        if secondStartPos >= 0 then Text.Middle(textToSearch, secondStartPos, 6) else null
)

Output:

Royel_2-1696831368636.png

 

Step 04: Split third match 

Click Add Column and then select Custom Column and pest the code, then extract the list and change data type to text

= Table.AddColumn(#"Changed Type2", "split_col_3", each Table.AddColumn(#"Changed Type4", "third", each 
    let
        textToSearch = [col],
        startPos = Text.PositionOf(textToSearch, "122"),
        secondStartPos = if startPos >= 0 then Text.PositionOf(Text.Middle(textToSearch, startPos + 3), "122", Occurrence.First) + startPos + 3 else -1,
        thirdStartPos = if secondStartPos >= 0 then Text.PositionOf(Text.Middle(textToSearch, secondStartPos + 3), "122", Occurrence.First) + secondStartPos + 3 else -1
    in
        if thirdStartPos >= 0 then Text.Middle(textToSearch, thirdStartPos, 6) else null
)[third])

 

Output:

Royel_3-1696831757617.png


Regards
Royel

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

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors