0
votes

I am trying to achieve a very simple thing in Powerapps. I have two collections:

  **collection1    collection2**
    *Column1          Column2*
       abc             jkl
       def             mno
       ghi             pqr

The collections will always have a one to one relationship between the records, what I need to do is just merge the two collections so I get one collection with two columns from the previous collections. The above data set should produce the following result:

    **collection3**
*column1       column2*
  abc           jkl
  def           mno
  ghi           pqr

I've tried different approaches but I always end up with tables in the column fields. It looks so simple, isn't there a simple solution to this kind of problem?

1

1 Answers

0
votes

Based on your question, you don't have any column that is common in the two collections that you want to use to "join" them - you want to join them by index instead, is that correct? If this is the case, you can use an expression like the one below:

Clear(Collection3);
ForAll(
    FirstN(
        [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],
        Min(CountRows(Collection1), CountRows(Collection2))),
    Collect(
        Collection3,
        Patch(
            {},
            Last(FirstN(Collection1, Value)),
            Last(FirstN(Collection2, Value)))));

This will create a collection with the number of items in the smaller collection, and within the ForAll operation it will collect a record to the new collection that consists of the combination of the matching records from the two collections (using the version of the Patch function that if you pass a record as the first parameter it will return a combination of all the records that were passed to it).