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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
ErikPettersson
Frequent Visitor

TextTrimEnd Query - Remove only 1 ending underscore

Hi,

 

I'm trying to trim the end of ID's with 2 distinct traits:

 

104297_190__

110201_130_L_

 

I want to remove the ending underscore and used the following formula: Text.TrimEnd(_,"_") and got the following result:

 

104297_190

110201_130_L

 

However, the result I wanted was the following (i.e. only removing the final underscore, not all ending underscores):

 

104297_190_

110201_130_L

 

Is there a way around this? 

 

Any help is much appreciated

4 REPLIES 4
Interkoubess
Solution Sage
Solution Sage

Hi @ErikPettersson,

 

Are you writing correctly the formula for Text.trimEnd? Because I tried with the same data and I called my Column column1 and it worked.

 

Check formula below;

Text.TrimEnd([Column1],"_")

Let us know if it does not work again

 

Ninter

Ok, how are you writing the query? This is how I write it and I get error now. External_Ref_Edge is the column Im trying to trim

 

Table.TransformColumns(#"Added Custom",{{"External_Ref_Edge", each Text.TrimEnd([External_Ref_Edge],"_"), type text}})

Please creat a column and enter the formula I gave.

Thank you.

Ninter
Greg_Deckler
Community Champion
Community Champion

Try this:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQwMbI0jze0NIiPV4rVAQoYGhgZGMYbGhvE+wBFYgE=", 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.SplitTextByEachDelimiter({"_"}, QuoteStyle.Csv, true), {"Column1.1", "Column1.2"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Column1.1", type text}, {"Column1.2", type text}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type1",{"Column1.2"})
in
    #"Removed Columns"


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
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.