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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
ExcelKnut
Frequent Visitor

Remove trailing commas

If values in a column contain a trailing comma, I need to remove it.  However, commas separating values within that column need to be kept.  I tried using Text.TrimEnd but that didn't work.  

 

Any help is greatly appreciated!!!

 

Jeff

 

 

1 ACCEPTED SOLUTION
dufoq3
Super User
Super User

Hi @ExcelKnut, what do you mean that Text.TrimEnd didn't work?

 

Before

dufoq3_0-1743168109935.png

After

dufoq3_1-1743168127786.png

let
    Source = #table(null, {{"Native American,"}, {"Asian, Black,"}}),
    Custom1 = Table.TransformColumns(Source, {{"Column1", each Text.TrimEnd(_, ",")}})
in
    Custom1

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

View solution in original post

12 REPLIES 12
dufoq3
Super User
Super User

Hi @ExcelKnut, what do you mean that Text.TrimEnd didn't work?

 

Before

dufoq3_0-1743168109935.png

After

dufoq3_1-1743168127786.png

let
    Source = #table(null, {{"Native American,"}, {"Asian, Black,"}}),
    Custom1 = Table.TransformColumns(Source, {{"Column1", each Text.TrimEnd(_, ",")}})
in
    Custom1

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

v-vpabbu
Community Support
Community Support

Hi @ExcelKnut,

 

As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?
If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.

 

Regards,
Vinay Pabbu

Hi @ExcelKnut,

 

May I ask if you have gotten this issue resolved?

If it is solved, please mark the helpful reply or share your solution and accept it as solution, it will be helpful for other members of the community who have similar problems as yours to solve it faster.

 

Regards,
Vinay Pabbu

Hi @ExcelKnut,

 

As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?
If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.

 

Regards,
Vinay Pabbu

SundarRaj
Solution Supplier
Solution Supplier

Hi @ExcelKnut , you could probably give a go at this solution and see if it suits you. I'll leave the code and output below. Thanks

SundarRaj_0-1742823940103.png

SundarRaj_1-1742823955887.png

 

Sundar Rajagopalan
bhanu_gautam
Super User
Super User

@ExcelKnut Add a new custom column with the following formula:

= Text.Replace(Text.TrimEnd([YourColumnName], ","), ",,", ",")




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Use Split by Delimiters, and start from the end.

 

--Nate

Thanks for your quick response.  Unfortunately, that didn't seem to solve the issue.  

 

Formula used:  Text.Replace(Text.TrimEnd([Race], ","), ",,", ",")

 

Example #1:   Native American,

Example #2:  Asian, Black,

Use this m
= if Text.EndsWith([YourColumnName], ",") then
Text.Start([YourColumnName], Text.Length([YourColumnName]) - 1)
else
[YourColumnName]




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Great formula but for some strange reason it's not removing the trailing comma. 

 

I copied the table into Excel and it shows the last character is a comma.

 

However, in Power Query, I added a column to just get the last character in that column, the commas do not appear.    Then, when I get the last two characters, the commas appear.  

 

Hi @ExcelKnut,

 

It looks like your data might have non-breaking spaces or invisible characters after the comma, which Power Query isn't recognizing as a simple trailing comma.

 

Try by removing removes leading and trailing spaces.

 

If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!


Regards,
Vinay Pabbu

Thanks Vinay, 

 

I'll give that a try.  I appreciate your time.

 

Jeff

Helpful resources

Announcements
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 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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