Forum Discussion
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
Hi ExcelKnut, what do you mean that Text.TrimEnd didn't work?
Before
After
let Source = #table(null, {{"Native American,"}, {"Asian, Black,"}}), Custom1 = Table.TransformColumns(Source, {{"Column1", each Text.TrimEnd(_, ",")}}) in Custom1
12 Replies
- bhanu_gautam
Super User
ExcelKnut Add a new custom column with the following formula:
= Text.Replace(Text.TrimEnd([YourColumnName], ","), ",,", ",")
- ExcelKnutFrequent Visitor
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,
- bhanu_gautam
Super User
Use this m
= if Text.EndsWith([YourColumnName], ",") then
Text.Start([YourColumnName], Text.Length([YourColumnName]) - 1)
else
[YourColumnName]
- nathancwatkins
Helper II
Use Split by Delimiters, and start from the end.
--Nate
- AnonymousNot applicable
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- AnonymousNot applicable
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- AnonymousNot applicable
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