Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Difference between single-column table and single-column collection?

Posted on by 5

Greetings everyone,

 

Here's a funny one.

 

The setup is the following:

  • I have a combo box linked to a choices column in a Sharepoint list.
  • I want to set the update field of the combo box using a collection:

2022-02-21 09-51-57.png

  • When I submit the form, I get no error message whatsoever, and all the fields are correctly written in the Sharepoint list except the content of the combo box.
  • But if instead I create a single column table manually in the update field, it works just fine:

2022-02-21 09-56-00.png

 

So, it looks like there's some format difference between a single column table created with brackets and a single column table from a collection?

 

What am I missing?

  • RandyHayes Profile Picture
    RandyHayes 76,308 on at
    Re: Difference between single-column table and single-column collection?

    @NDUQAM 

    Not really documented - it is more of a "knowing your data" sort of thing.

    The only thing that is close is the docs on working with tables.

     

    There are two things at play here.

    1) You are most obviously working with a Choice column.  A Choice column WILL expect a record that has a Value column.

    2) Column names.

     

    So, starting with #2...with your first formula you are specifically stating - give me a table or record with a "Title" column.   Anytime you "dot" append a table and provide a column name, PowerApps will return a table with JUST that column.  It is equivalent to:  ShowColumns(testCollection, "Title")  This will return a table with just a Title column.  This can be short-handed as testCollection.Title

    So, the result of that is a table that just has the Title column.  Records will be:  {Title: "Something"}

    That will not work when you need records that are:  {Value: "Something"} (which is what a choice column wants).

     

    However, when you do: ["Something", "else"]  This is short-hand for:

    Table({Value:"Something"}, {Value:"else"})

    This is because pretty much everything in PowerApps works from the Value column name...so PowerApps will take the shorthand and create a table with a Value column name.

     

    AND...(for #1), since you need records with a column name of Value, then the shorthand will work.

     

    And finally, with the formula provided, the RenameColumns is used to simply change the name of the column from Title to Value.

     

    This is another compelling reason to avoid naming your own columns and to use the columns that are already defined in sources and functions.

     

    Hopefully that is clear and more helpful for you.

  • NDUQAM Profile Picture
    NDUQAM 5 on at
    Re: Difference between single-column table and single-column collection?

    Thanks a lot, @RandyHayes. It works just fine, and the explanation is much appreciated.

     

    I've been searching about this for days. Is this documented somewhere?

  • Verified answer
    RandyHayes Profile Picture
    RandyHayes 76,308 on at
    Re: Difference between single-column table and single-column collection?

    @NDUQAM 

    There is no difference between a collection and a table except that a collection you can add/remove and edit records.

     

    The difference, however, with your formulas are that, in the first example, you are stating a table with the Title column.

    In the second, you are NOT specifying a column for your table, so PowerApps automatically assigns a Value column.

     

    So, if you are attempting to write to a column that requires a record (like a Choice column), then you need to supply a table (if multi-select) with a Value column.  

    That is why your second one works.  The first one will be submitting a table with a Title column...which will not work.

     

    If you need to use a collection for some reason, then you would need to change the formula of your first one to:

    RenameColumns(testCollection.Title, "Title", "Value")

     

    I hope this is helpful for you.

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

October 2024 Newsletter…

October 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #4 How to Conntact Support…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 142,473

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,659

Leaderboard