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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

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
Solution Sage
Solution Sage

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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors