Skip to main content

Notifications

Power Apps - Power Apps Pro Dev & ISV
Suggested answer

AddColumns Not Working

(0) ShareShare
ReportReport
Posted on by 33
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 33 on at
    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 143,867 on at
    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 161 on at
    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 33 on at
    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 161 on at
    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 33 on at
    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 33 on at
    AddColumns Not Working
    Andriana, When I used your code I got : "The specified column 'ClosedTag' does not exist".
  • AndrianaO Profile Picture
    AndrianaO 161 on at
    AddColumns Not Working
    Can you show how you create the original collection before you run AddColumns function? It is important to know if the column ClosedTag already exists (even though all the values in that column are empty). I suspect that instead of AddColumns you should try using:
     
    ForAll(OpenRequirements,Patch(OpenRequirements,ThisRecord,{ClosedTag:
    Concatenate(ThisRecord.ID,",",ThisRecord.Title)}))
     
    This code will update every record in your collection to have the correct value in ClosedTag column if this column do really exists
     
  • JK-25091409-0 Profile Picture
    JK-25091409-0 33 on at
    AddColumns Not Working
  • ronaldwalcott Profile Picture
    ronaldwalcott 1,345 on at
    AddColumns Not Working
    Show the statement where you adding columns to OpenRequirements

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 143,867

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,174

Leaderboard