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

Community site session details

Session Id : TRQ6zkCv0v7WBQzrmlcX9W
Power Apps - Building Power Apps
Answered

RenameColumns not working as expected

Like (0) ShareShare
ReportReport
Posted on 7 Apr 2017 13:40:52 by

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

 

 

  • Andy77-2 Profile Picture
    85 on 03 Aug 2018 at 06:20:53
    Re: RenameColumns not working as expected

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

  • Meneghino Profile Picture
    6,949 on 07 Apr 2017 at 15:43:17
    Re: RenameColumns not working as expected

    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.

  • Community Power Platform Member Profile Picture
    on 07 Apr 2017 at 15:36:16
    Re: RenameColumns not working as expected

    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?

  • Verified answer
    Meneghino Profile Picture
    6,949 on 07 Apr 2017 at 15:28:03
    Re: RenameColumns not working as expected

    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
    on 07 Apr 2017 at 15:20:22
    Re: RenameColumns not working as expected

    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...

     

     

  • Meneghino Profile Picture
    6,949 on 07 Apr 2017 at 15:19:22
    Re: RenameColumns not working as expected

    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?

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

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410 Super User 2025 Season 2

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 2

Loading complete