web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / RenameColumns not work...
Power Apps
Answered

RenameColumns not working as expected

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I've found when patching data back into a source from a collection, it helps to make sure your collection and source don't have the same column names as PowerApps can't determine the correct scope for the columns.  Yes, it's nice and easy if you're just appending and you can collect straight back into the source, but patching is another story it seems.

 

Creating the collection from the source is also nice and easy with ClearCollect(Collection, Source) - so I figured I'd try use RenameColumns after the fact to differentiate my collected columns from my source columns.  That's when the weirdness started;

 

ClearCollect(StageTable, QTable);
ClearCollect(CollectQuestions, RenameColumns(StageTable, "Category", "CollectCat"),
RenameColumns(StageTable, "QID", "CollectQID"),
RenameColumns(StageTable, "Questions", "CollectQ"))

Here's the staging collection followed by the new collection;

StageTableStageTableNew Collection with...???New Collection with...???

So, I'm pretty sure it's supposed to rename new columns...What am I doing wrong here?

 

Kind regards,

 

R

 

 

Categories:
I have the same question (0)
  • Meneghino Profile Picture
    6,949 on at

    Hi @Anonymous

    The result you show is what I would expect with the code you have shown.

    Could you please be more specific about what you would expect?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I was expecting a new collection with data from the original source, but with different column names....

    Whereas I seem to have added columns instead of just renaming them...

     

     

  • Verified answer
    Meneghino Profile Picture
    6,949 on at

    OK, I think this is what you are looking for:

     

    ClearCollect(StageTable, QTable);
    ClearCollect(CollectQuestions, RenameColumns(RenameColumns(RenameColumns(StageTable, "Questions", "CollectQ"), "QID", "CollectQID"), "Category", "CollectCat"))

    Does it work?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    It did indeed - I would never have gotten there - thanks!

     

    So i'm guessing you have to only have one update item for RenameColumns meaning you have to nest it - not sure I understand the logic though, any chance you can explain it to me?

  • Meneghino Profile Picture
    6,949 on at

    With ClearCollect(A, B, C, D) you were collecting B then C then D in A.

    The only reason to nest the RenameColumns is that for some reason which is unclear to me RenameColumns only accepts one column to be renamed at a time, so you have to nest three of them.  The function should be renamed RenameColumn or fixed to accept more than one column at a time.

  • Andy77-2 Profile Picture
    85 on at

    Thanks again Meneghino, your answers are always on point. much appreciated.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 505

#2
WarrenBelz Profile Picture

WarrenBelz 502 Most Valuable Professional

#3
Haque Profile Picture

Haque 324

Last 30 days Overall leaderboard