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 / AddColumns to an exist...
Power Apps
Answered

AddColumns to an existing collection - getting error that column name already exists, even though it doesn't

(0) ShareShare
ReportReport
Posted on by 49

I'm trying to add 2 columns to an existing 1-column collection.  In case it matters, the 1-column collection (colVPOSCollectedSkills) is produced with Distinct() to grab an unduplicated list of skills that have been assessed for a selected student.  Due to the use of Distinct(), the column name is Value.

1.png

 

I want to add another column (ViewProfics) to this existing collection with the value false.  I have tried locating the code as:

  1. a second item within the initial ClearCollect
  2. an additional step immediately after the initial ClearCollect, and
  3. a separate button for testing purposes.

Here are the various code snippets I've tried (separately) in all the locations described above.  Every time, though I get the error that the column name already exists, even though it doesn't.

Collect

 

Collect(
 colVPOSCollectedSkills,
 AddColumns(
 colVPOSCollectedSkills,
 "ViewProfics",
 false
 )
)

 

ClearCollect

 

ClearCollect(
 colVPOSCollectedSkills,
 AddColumns(
 colVPOSCollectedSkills,
 "ViewProfics",
 false
 )
)

 

Collect with the collection value only in the AddColumns function

 

Collect(
 AddColumns(
 colVPOSCollectedSkills,
 "ViewProfics",
 false
 )
)

 

AddColumns without any Collect or ClearCollect function

 

AddColumns(
 colVPOSCollectedSkills,
 "ViewProfics",
 false
)

 

There are some older posts on this error, but none of them got me to the finish line.  Hoping one of you can!  Thanks!

Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    154,799 Most Valuable Professional on at

    Hi @RB2GSO ,

    You need to use a different name for the new collection.

    ClearCollect(
     colVPOSCollectedSkills2,
     AddColumns(
     colVPOSCollectedSkills,
     "ViewProfics",
     false
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • CU15091556-0 Profile Picture
    49 on at

    Thanks @WarrenBelz!  That works, so I'm unstuck.

     

    Is that a way to workaround a likely glitch I've created elsewhere or does PowerApps simply not intend to allow us to add columns to an existing collection?  The documentation on AddColumns() makes it sounds like it should be a simple thing to tack extra columns on.

     

    I ask because, if I'm doing something boneheaded elsewhere that requires this workaround, I'd love to know it so I don't have to have a bunch of inter-step collections.

     

    Thanks!

    Robin

  • WarrenBelz Profile Picture
    154,799 Most Valuable Professional on at

    @RB2GSO ,

    Yes, but it needs to be done by creating a new data set and Power Apps does not seem to like using the same one. You can try this

    ForAll(
     Sequence(CountRows(colVPOSCollectedSkills)),
     Patch(
     Index(
     colVPOSCollectedSkills,
     Value
     ),
     {ViewProfics: false}
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

     

  • Suggested answer
    HandyK Profile Picture
    2 on at
    In case it helps, I have avoided creating a third collection (first being the initial data, second being the Distinct collection), by adding the columns to the Distinct call:
     
    ClearCollect(colUniqueCollection,
        ForAll(
            Distinct(colInitialCollection, ThisRecord),
            AddColumns(Value, NewColumnName, Expression)
        )
    )
     
    So, it would look something like this:
     
    ClearCollect(colVPOSCollectedSkills,
        ForAll(
            Distinct([Your initial collection], ThisRecord),
            AddColumns(Value, ViewProfics, false)
        )
    )
     
    It might be worth checking out if it works for your scenario.

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 536

#2
WarrenBelz Profile Picture

WarrenBelz 426 Most Valuable Professional

#3
Haque Profile Picture

Haque 305

Last 30 days Overall leaderboard