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! Request now

Reply
Anonymous
Not applicable

How do I return the text after the second underscore?

Hello!

 

I have a column with text like:

QWER_SDFGWE_QERGR

QWERG_WER_WEGR

 

How do I only keep the text after the second underscore?

What is the DAX, Power Query and EXCEL code to do that?

 

Thanks!

 

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

The Power Query:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjI2MY0PdnFzD3eNNwRylGJjAQ==", 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}}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "Column1", Splitter.SplitTextByDelimiter("_", QuoteStyle.Csv), {"Column1.1", "Column1.2", "Column1.3"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Column1.1", Int64.Type}, {"Column1.2", type text}, {"Column1.3", Int64.Type}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type1",{"Column1.1", "Column1.2"})
in
    #"Removed Columns"

 

The DAX:

Column = 
    RIGHT(
        [Column1],
        LEN([Column1]) - 
            SEARCH(
                "_",
                [Column1],
                SEARCH("_",[Column1],1) + 1
            )
    )

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
hmericchan
Frequent Visitor

I would use Text.AfterDelimiter() twice to get the right most delimiter, if that's always the last one. I like to directly type the formula in m instead of using the split column by delimiter as it can combine multiple steps, such as have Text.Clean() or Text.Trim(). 😅

Anonymous
Not applicable

Hi

 

Select the column you want to extract the data from .

Go to the transform tab in the ribbon and click on extract.

Select Text after delimiter from dropdown

A new dialog box will appear. 

Write down the delimiter and mention the delimiter position from advanced options.

 

You are good to go.

 

Thanks,

Uday

Greg_Deckler
Community Champion
Community Champion

The Power Query:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjI2MY0PdnFzD3eNNwRylGJjAQ==", 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}}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "Column1", Splitter.SplitTextByDelimiter("_", QuoteStyle.Csv), {"Column1.1", "Column1.2", "Column1.3"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Column1.1", Int64.Type}, {"Column1.2", type text}, {"Column1.3", Int64.Type}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type1",{"Column1.1", "Column1.2"})
in
    #"Removed Columns"

 

The DAX:

Column = 
    RIGHT(
        [Column1],
        LEN([Column1]) - 
            SEARCH(
                "_",
                [Column1],
                SEARCH("_",[Column1],1) + 1
            )
    )

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

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