Blog
Data - How to remove trailing comma all rows in a table
February 20. 2025
If you're struggling with trailing commas in your Power Apps data, this post describes how to easily remove trailing commas from all rows in a table.
In Power Apps, a common issue developers face is how to deal with trailing commas in data fields, which can lead to formatting problems and errors in data processing.
This article describes how to remove trailing commas from all rows in a table using Power Apps.
Creating a Collection with Sample Data
To demonstrate the technique let's start by creating a collection with some sample data. The name of this collection is colEquipment.
This collection simulates a table with rows containing comma-separated lists of IT equipment. Note how some rows have trailing commas whereas others don't.
ClearCollect(Here's how this collection looks when loaded into a data table control.
colEquipment,
{ID: 1, Items: "Laptop, Monitor, Keyboard,"},
{ID: 2, Items: "Mouse, Headset"},
{ID: 3, Items: "Printer, Scanner,"},
{ID: 4, Items: "Router, Modem"},
{ID: 5, Items: "Webcam, Microphone,"},
{ID: 6, Items: "Docking Station"},
{ID: 7, Items: "External Hard Drive, USB Hub,"},
{ID: 8, Items: "Projector, Screen"},
{ID: 9, Items: "Smartphone, Tablet,"},
{ID: 10, Items: "Speakers, Surge Protector"}
);

Applying the Logic to Remove Trailing Commas
To remove the trailing commas from the Items field in all rows of the collection, we can add a button and set the OnSelect property to the following:
UpdateIf(
colEquipment,
true,
{
Items: If(
Right(Items, 1) = ",",
Left(Items, Len(Items) - 1),
Items
)
}
);
In this formula, the UpdateIf function iterates through each row in the colEquipment collection.
- The If function checks if the last character of Items is a comma.
- If true, it removes the trailing comma using the Left function, which returns all characters except the last one.
- If false, it retains the original Items value.
The screenshot below illustrates the result after running the formula. As we can see, all trailing commas have been removed.

Conclusion
To remove all trailing commas from all rows in a table within Power Apps, this post described how to call the UpdateIf function, conditionally check for a trailing comma, and remove it if present.
- Categories:
- data
Related posts
- Data - How to find the common rows from 3 or more collections
- Data - How to show the distinct rows from 2 data sources or collections
- Data - How to implement circular rotational date sorting
- Bug - What to do when the data section of the Power Apps Maker portal doesn't work
- Data - Combine columns from separate tables into a single table
- Formula - Transposing/converting rows to columns- an almost impossible task?
- Data - How to rename field names in a record
- Data - How to hide duplicate rows in a gallery / show distinct multiple columns in a gallery
- Data - Retrieving news/forum/blog articles with RSS
- Data - How to sort by partial numbers in a text field
- Data - How to return the last record from a table
- Data - How to create bulk test/dummy records with random values
- Data - 3 things you should know before using the MySQL or PostgreSQL connectors
- Data - A walkthrough of how to migrate the data source of an app from Excel to Sharepoint
- Data - How to enforce unique values (or prevent duplicate values) in one or more columns
- Data - How much mobile data does Power Apps consume? What ways can we minimise this?
- Data - How to save and retrieve Google calendar entries
- Data - How to save and retrieve Google contacts
- SQL - Caution! This is how users can hack shared SQL connections
- SharePoint – 2 Mistakes to avoid when importing Excel data
- SQL - Don't let this DateTime bug catch you out!
- Settings - What's the purpose of the "Explicit Column Selection" Setting?
- SQL Server for Beginners Part 3 - Installing On-Premises Gateway
- SQL Server for Beginners Part 2 - Installing Management Studio
- SQL Server for Beginners Part 1 - Installing SQL Server
- Searching data–What you need to know about case sensitivity
- Images - How to create images that can change depending on data
- Excel - Reasons NOT to use Excel as a data source
- SharePoint - What you need to know about Filtering Data
- Formulas - Generating Row Numbers