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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
vanessafvg
Community Champion
Community Champion

Power Query Question on removing last character if a certain value is present

I have a column that has 1.02 20.1 etc in, but someone has inputted some of them like 1.02. and 52.01

 

I only want to remove a . if it is the last character, any idea on how to do that?





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




1 ACCEPTED SOLUTION

Maybe you can use trim to trim all trailing dots.

 

On the Transform tab, select your column and choose Format - Trim,

Then adjust the code and change

Text.Trim

to:

each Text.TrimEnd(_,".")

 

Specializing in Power Query Formula Language (M)

View solution in original post

5 REPLIES 5
Greg_Deckler
Community Champion
Community Champion

Here is one way:

 

let
    Source = Csv.Document(File.Contents("C:\temp\powerbi\decimals.csv"),[Delimiter=",", Columns=1, Encoding=1252, QuoteStyle=QuoteStyle.None]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
    #"Promoted Headers" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Promoted Headers", "Value", Splitter.SplitTextByEachDelimiter({"."}, QuoteStyle.Csv, true), {"Value.1", "Value.2"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Value.1", type number}, {"Value.2", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type1", "Custom", each if [Value.2] = null then [Value.1] else [Value.1] + [Value.2]/10),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Value.1", "Value.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...

Maybe you can use trim to trim all trailing dots.

 

On the Transform tab, select your column and choose Format - Trim,

Then adjust the code and change

Text.Trim

to:

each Text.TrimEnd(_,".")

 

Specializing in Power Query Formula Language (M)

Much more elegant than what I was doing.  Thank you @MarcelBeug 

works like a charm thanks @MarcelBeug





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Hi @vanessafvg,

Please try the Text.TrimEnd function as @MarcelBeug posted. Please feel free to ask if you have any other issue.

Thanks,
Angelia

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.