Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin 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.
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
Solved! Go to Solution.
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
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
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
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
@ExcelKnut Add a new custom column with the following formula:
= Text.Replace(Text.TrimEnd([YourColumnName], ","), ",,", ",")
Proud to be a Super User! |
|
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]
Proud to be a Super User! |
|
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
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
14 | |
13 | |
12 | |
8 | |
8 |
User | Count |
---|---|
17 | |
10 | |
7 | |
7 | |
7 |