Skip to main content
Community site session details

Community site session details

Session Id : ZIwzCDZrneY40O9PY8+Od1
Power Apps - Building Power Apps
Answered

Adding items to an existing column in a collection from a column in a table

Like (0) ShareShare
ReportReport
Posted on 29 Nov 2023 19:15:01 by 74

Hi!

I have a dropdown that shows items in a column in a table to filter items and I want to include the "All" option:

So...

In a multi column Table01

The contents of Column01 are...

Column01

Item 1

Item 2

Item 3

etc...

 

I was hoping to get this in the "Result" column of a one column collection:

Result

All

Item 1

Item 2

Item 3

etc...

 

To do so I wrote the following snippet in On Visible in the specific screen:

 

ClearCollect(coll_Jeepers, {Result: "All"});
Collect(coll_Jeepers, Distinct(Table01, Column01)) 

 

Instead I get the two column collection collJeepers like so:

Result             Value

All

                     Item 1

                     Item 2

                     Item 3

                     etc

 

I can choose either for my dropdown, but not the consolidated one column "Result" collection as required.

 

Btw: I'm using the Distinct function to make the results a one column table, but I don't really need it. All the values in that column will be unique.

 

Any thoughts as to what I'm doing wrong?

 

Thanks!

MIchael

 

                       

 

  • MichaelBranches Profile Picture
    74 on 30 Nov 2023 at 16:23:33
    Re: Adding items to an existing column in a collection from a column in a table

    Hi MudassarSZ365!

     

    Thanks for the latest proposed solution. It didn't work but will accept it because it gave me the inspiration to arrive at the solution (I even sorted the dropdown list with a little trick: " Todos" (" All") has a leading space to remain at the top after sorting).  

     

    // Works Ok and Sorted
    ClearCollect(
    collectProyecto,
    {Value: " Todos"}
    );

    Collect(
    collectProyecto,
    Distinct(Sort(tblProyectos,Proyecto,SortOrder.Ascending),Proyecto)
    )
    ;

     

    Important: The Dropdown has to be set for Items -> CollectProyecto and Value -> Value

     

    Thanks!

  • Verified answer
    MudassarSZ365 Profile Picture
    591 on 30 Nov 2023 at 12:12:56
    Re: Adding items to an existing column in a collection from a column in a table

    @MichaelBranches ,

    you can try this 

    ClearCollect(coll_Jeepers, {Result: "All"});
    Collect(coll_Jeepers, RenameColumns(Distinct(Table01, Column01), "Result", "Result"));

    Try the updated code, and if it resolves your issue, please consider accepting this solution. 😊

  • MichaelBranches Profile Picture
    74 on 30 Nov 2023 at 00:46:52
    Re: Adding items to an existing column in a collection from a column in a table

    Hi MudassarSZ365

    Thanks for your input. Unfortunately, it isn't working either:

     

    Collect 03.png

     

    Collect 03b.png

     

    I also tried changing the order to have "All" at the beginning (Changing the position AND the Collect / ClearCollect) but it still gave the same error.

     

  • MichaelBranches Profile Picture
    74 on 30 Nov 2023 at 00:28:18
    Re: Adding items to an existing column in a collection from a column in a table

    Here it is:

    Collect 02.png

  • mmbr1606 Profile Picture
    13,477 Super User 2025 Season 2 on 29 Nov 2023 at 20:57:28
    Re: Adding items to an existing column in a collection from a column in a table

    can u provide the whole error msg and maybe copy paste it in here?

     

    thanks

  • MichaelBranches Profile Picture
    74 on 29 Nov 2023 at 20:50:51
    Re: Adding items to an existing column in a collection from a column in a table

    Hi @mmbr1606 

    Thanks for your help. 

    Unfortunately, I'm getting this error:

     

    Collect 01.png

    btw; The vertical bar after the comma is just the cursor

     

  • MudassarSZ365 Profile Picture
    591 on 29 Nov 2023 at 19:20:36
    Re: Adding items to an existing column in a collection from a column in a table

    Hi @MichaelBranches ,

    You can try this code

     

    ClearCollect(
     coll_Jeepers, 
     AddColumns(
     Distinct(Table01, Column01), 
     "Result", 
     Result
     )
    );
    Collect(
     coll_Jeepers, 
     {Result: "All"}
    );

     

    However, you will notice that the "All" item is added to the end of the collection. If you want "All" to appear as the first item in the dropdown, you should reverse the order of the ClearCollect and Collect like this:

     

    ClearCollect(coll_Jeepers, {Result: "All"});
    Collect(coll_Jeepers, Table01.Column01);

     

    If this solution helps you, please consider accepting it. 😊

  • mmbr1606 Profile Picture
    13,477 Super User 2025 Season 2 on 29 Nov 2023 at 19:20:17
    Re: Adding items to an existing column in a collection from a column in a table

    hello @MichaelBranches 

     

    try the following approach:

     

    ClearCollect(coll_Jeepers, {Result: "All"});
    ForAll(Distinct(Table01, Column01), Collect(coll_Jeepers, {Result: Result}));

     

    Let me know if my answer helped solving your issue.
    If it did please accept as solution and give it a thumbs up so we can help others in the community.

    Greetings

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!

Loading complete