Skip to main content

Notifications

Power Apps - Power Apps Pro Dev & ISV
Answered

AddColumns Not Working

Like (0) ShareShare
ReportReport
Posted on 18 Dec 2024 19:09:32 by 35
Everytime I use "AddColumns" I get an error as I type in the name of the new column.   The column gets added to the collection before the command is entered, and it says there is a duplicate column.   
 
 
  • JK-25091409-0 Profile Picture
    JK-25091409-0 35 on 02 Jan 2025 at 18:59:17
    AddColumns Not Working
    @WarrenBelz @AndrianaO​​​​​​​​​​​​​​

    Your code worked, however there are other places where I have to collect one at a time so I can't do it that way.  However I think it's because I have 2900 records in my collection.  When I used AddColumns on smaller collections it worked.   
     
  • WarrenBelz Profile Picture
    WarrenBelz 144,215 on 26 Dec 2024 at 01:53:46
    AddColumns Not Working
    @JK-25091409-0​​​​​​​
    A quick follow-up to see if you received the answer you were looking for or if you need further assistance.

    Please click Does this answer your question 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 a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    Buy me a coffee
  • Verified answer
    WarrenBelz Profile Picture
    WarrenBelz 144,215 on 23 Dec 2024 at 20:45:12
    AddColumns Not Working
    Try it all together like this. 
    With(
       {
          _Data: 
          Split(
             LookUp(
                L3ProcessMain, 
                ID = L3P.ID,
      Requirements ) ";" ) }, ClearCollect( RequirementsC, AddColumns( Filter( Requirements, ID in _Data.Value ), TitleTag, ID & "." & Title ) ) )
     
     
    Please click Does this answer your question 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 a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    Buy me a coffee
  • JK-25091409-0 Profile Picture
    JK-25091409-0 35 on 20 Dec 2024 at 22:28:38
    AddColumns Not Working
    @WarrenBelz​​​​​​​
     
    Copying and pasting from Notepad didn't work.
     
    I have a ListBox whose OnSelect starts the whole process:
     
    Set(lookupList, Split(LookUp(L3ProcessMain, ID = L3P.ID, Requirements), ";"));
    ClearCollect(RequirementsC, Filter(Requirements, ID in lookupList));
     
    Then RequirementsC is used to populate another ListBox.  I want the concatenated string to show up as text in the ListBox, but I don't just want the text, I need the entire RequirementsC record to transfer to another collection.
     
    Here is what I have in my "Items" property of the second ListBox.   This is where I'm getting the error "TitleTag already exists"
     
    AddColumns(RequirementsC, TitleTag, Concatenate(ID, ". ", Title))
  • WarrenBelz Profile Picture
    WarrenBelz 144,215 on 20 Dec 2024 at 21:22:05
    AddColumns Not Working
    Thanks for the tag.
    @JK-25091409-0​​​​​​​
    Before trying anything else, type the formula in NotePad and paste it all in at once rather than typing it.
    It would also be very useful to have the current attempted code in Text (some of it is hidden in the screenshot) and also where it is being used. I also assume RequirementsC is showing all columns from Requirements and all the columns are being shown in the image above.

  • AndrianaO Profile Picture
    AndrianaO 181 on 20 Dec 2024 at 17:05:56
    AddColumns Not Working
    Hi @WarrenBelz, can you please have a look at this problem?
     
    When @JK-25091409-0 tried to use AddColumns() function they got an error "The column named 'ClosedTag' already exists", but when they tried to use Patch() function to update this column fields they got an error "The specified column 'ClosedTag' does not exist".
     
    I have no idea how it can be possible, so I decided to ask you if you can help.
  • JK-25091409-0 Profile Picture
    JK-25091409-0 35 on 20 Dec 2024 at 16:46:57
    AddColumns Not Working
    It's still doing that, you can see the RequirementsC has a ClearCollect, and it pulls from the Requirements table which does not have a
    "TitleTag" column.   Actually if you look at the image of the collection above, the new columns are in fact showing up in RequirementsC.  That must be the problem, AddColumns is adding the new column to the collection instead of returning a new table.

    After some testing I think that's it, if you AddColumns to a Collection, they get added to the collection.  If you AddColumns to a table, it returns a new table.

    This works for me (Requirements is an actual table):

    AddColumns(Requirements, TitleTag, Concatenate(ID, ". ", Title))

  • Suggested answer
    AndrianaO Profile Picture
    AndrianaO 181 on 19 Dec 2024 at 21:10:39
    AddColumns Not Working
    Oh, that is a good sign that the error disappeared and the column is expected not to show. The AddColumns() function does not create a column in the table you pass as a parameter to this function. You can read about it in the documentation
     
    That is why you need to add the results of your AddColumns() function to a new collection:
     
    Try this formula
     
    ClearCollect(colRequirementsC,AddColumns(RequirementsC, TitleTag, Concatenate(ID, ". ", Title)));
     
    The new column should appear in a new colRequirementsC table
  • JK-25091409-0 Profile Picture
    JK-25091409-0 35 on 19 Dec 2024 at 20:47:40
    AddColumns Not Working
    I added this to the OnSelect of the list box I am choosing from:
     
    AddColumns(RequirementsC, TitleTag, Concatenate(ID, ". ", Title));
     
    I do not get a 'column exists' error, and the column does not show up under the collections variable.
  • JK-25091409-0 Profile Picture
    JK-25091409-0 35 on 19 Dec 2024 at 19:45:12
    AddColumns Not Working
    Andriana, When I used your code I got : "The specified column 'ClosedTag' does not exist".

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #9 Get Recognized…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 144,215

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,290

Leaderboard
Loading started