In this blog, we are going to see how to rename the columns in a PowerApps collection. Here we have a collection Col_GrosseryInventory containing ID, Name, and Quantity columns.
//Create a collection
ClearCollect(Col_GrosseryInventory,
{ID:1, Name: "Pasta", Quantity: 12},
{ID:2, Name: "Rice", Quantity: 30},
{ID:3, Name: "Butter", Quantity: 40}
);
Col_GrosseryInventory
ID |
Name |
Quantity |
1 |
Pasta |
12 |
2 |
Rice |
30 |
3 |
Butter |
40 |
To rename the column Quantity with Stock, we need to use RenameColumns function like below code snippet,
//Change the column name code
ClearCollect(
Col_GrosseryStock,
RenameColumns(Col_GrosseryStock,"Quantity","Stock"
)
);
Output
Col_GrosseryStock
ID |
Name |
Stock |
1 |
Pasta |
12 |
2 |
Rice |
30 |
3 |
Butter |
40 |
To rename multiple columns using RenameColumns in PowerApps,
//Change multiple column names code
ClearCollect(
Col_GrosseryDetails, RenameColumns(Col_GrosseryStock,"ID","ProductCode","Name","Product")
);
Output
Col_GrosseryDetails
ProductCode |
Product |
Stock |
1 |
Pasta |
12 |
2 |
Rice |
30 |
3 |
Butter |
40 |
That’s it, you have seen how to rename the columns in a power apps collection. Feel free to fill up the comment box below if you need any further assistance.