web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id : 0Ol8jlPf5nsnaOnTzMjoCe
Power Apps - Building Power Apps
Answered

Combine Tables to show in a new DataTable

Like (0) ShareShare
ReportReport
Posted on 9 Jul 2018 12:59:24 by

Hi,

 

I have several Strings that I split with the Split function. I then get several different tables... How is it possible to combine these into one table as the strings i am spliting have realation to another.

 

Eks

s1 = "11,21,31"

s2 = "12,22,32"

s3 = "13,23,33"

 

Split on "," gives me 3 different tables..But i want ->

 

Col 1 | Col2 | Col3 |

---------------------------

 11     |   21   |    31

 12     | 22     |  32

 13     |  23    | 33

  • Verified answer
    v-xida-msft Profile Picture
    on 10 Jul 2018 at 11:43:03
    Re: Combine Tables to show in a new DataTable

    Hi @Anonymous,

     

    Thanks for your feedback, I afraid that there is no way to achieve your needs in PowerApps currently.

     

    If you would like this feature to be added in PowerApps, please submit an idea to PowerApps Ideas Forum:

    https://powerusers.microsoft.com/t5/PowerApps-Ideas/idb-p/PowerAppsIdeas

     

    Best regards,

    Kris

  • Community Power Platform Member Profile Picture
    on 10 Jul 2018 at 10:34:26
    Re: Combine Tables to show in a new DataTable

    But this don't work when the number of elements varies.. I would like a general method for iterating over the splitted elements. 

     

    In any other language i would just wrote a for-loop where i indexed on the splitted string

    For example something like this

    for i = 0 ; i<= s1.split(",").lenght() ; i++ :

         e1 = s1.split(",")[i]

         e2 = s2.split(",")[i]

         e3 = s3.split(",")[i]

         ...do something

     

    Are there not any methods of doing a normal for-loop in PowerApps?

  • v-xida-msft Profile Picture
    on 10 Jul 2018 at 08:47:01
    Re: Combine Tables to show in a new DataTable

    Hi @Anonymous,

     

    I agree with @CarlosFigueira's thought almost. If you want to combine multiple tables into one table as below:

    Col 1 | Col2 | Col3 |
    ---------------------
     11 | 12 | 13
     21 | 22 | 23
     31 | 32 | 33

    Please take a try with the following workaround:13.JPG

     

     

    Set the OnVisible property of the first screen to following formula:

    UpdateContext({s1:"11,21,31"});UpdateContext({s2:"12,22,32"});UpdateContext({s3:"13,23,33"});
    Clear(Collection2);
    Collect(Collection2,{
    Col1:First(Filter(Split(Concatenate(s1,",",s2,",",s3),","),StartsWith(Result,"1"))).Result,
    Col2:Last(FirstN(Filter(Split(Concatenate(s1,",",s2,",",s3),","),StartsWith(Result,"1")),2)).Result,
    Col3:Last(Filter(Split(Concatenate(s1,",",s2,",",s3),","),StartsWith(Result,"1"))).Result
    });
    Collect(Collection2,{
    Col1:First(Filter(Split(Concatenate(s1,",",s2,",",s3),","),StartsWith(Result,"2"))).Result,
    Col2:Last(FirstN(Filter(Split(Concatenate(s1,",",s2,",",s3),","),StartsWith(Result,"2")),2)).Result,
    Col3:Last(Filter(Split(Concatenate(s1,",",s2,",",s3),","),StartsWith(Result,"2"))).Result
    });
    Collect(Collection2,{
    Col1:First(Filter(Split(Concatenate(s1,",",s2,",",s3),","),StartsWith(Result,"3"))).Result,
    Col2:Last(FirstN(Filter(Split(Concatenate(s1,",",s2,",",s3),","),StartsWith(Result,"3")),2)).Result,
    Col3:Last(Filter(Split(Concatenate(s1,",",s2,",",s3),","),StartsWith(Result,"3"))).Result
    })

    Set the Items property of the Data table control to following:

    Collection2

     

     

    On your side, you should reference to the following formula:

    Clear(Collection2);
    Collect(Collection2,{
     Col1:First(Filter(Split(Concatenate(s1,",",s2,",",s3),","),StartsWith(Result,"1"))).Result,
     Col2:Last(FirstN(Filter(Split(Concatenate(s1,",",s2,",",s3),","),StartsWith(Result,"1")),2)).Result,
     Col3:Last(Filter(Split(Concatenate(s1,",",s2,",",s3),","),StartsWith(Result,"1"))).Result
    });
    Collect(Collection2,{
     Col1:First(Filter(Split(Concatenate(s1,",",s2,",",s3),","),StartsWith(Result,"2"))).Result,
     Col2:Last(FirstN(Filter(Split(Concatenate(s1,",",s2,",",s3),","),StartsWith(Result,"2")),2)).Result,
     Col3:Last(Filter(Split(Concatenate(s1,",",s2,",",s3),","),StartsWith(Result,"2"))).Result
    });
    Collect(Collection2,{
     Col1:First(Filter(Split(Concatenate(s1,",",s2,",",s3),","),StartsWith(Result,"3"))).Result,
     Col2:Last(FirstN(Filter(Split(Concatenate(s1,",",s2,",",s3),","),StartsWith(Result,"3")),2)).Result,
     Col3:Last(Filter(Split(Concatenate(s1,",",s2,",",s3),","),StartsWith(Result,"3"))).Result
    })

     

    Best regards,

    Kris

  • Community Power Platform Member Profile Picture
    on 10 Jul 2018 at 07:29:47
    Re: Combine Tables to show in a new DataTable

    And I do not know have many values the splitted string will give me. All I know is that they have the same amount of values.

  • Community Power Platform Member Profile Picture
    on 10 Jul 2018 at 07:05:30
    Re: Combine Tables to show in a new DataTable

    What if I would have it like this -- >

     

    s1 = "11,21,31"

    s2 = "12,22,32"

    s3 = "13,23,33"

     

    Col 1 | Col2 | Col3 |

    ---------------------------

     11     |   12   |    13

     21     | 22     |  23

     31     |  32   | 33

  • CarlosFigueira Profile Picture
    on 09 Jul 2018 at 13:50:43
    Re: Combine Tables to show in a new DataTable

    You'll need to Collect those splitted strings into a new collection, but it can be done, by extracting each item using the First/FirstN/Last functions. In your example, you'd use something along the lines of the expression below:

    Clear(coll);
    ClearCollect(temp, Split(s1, ","));
    Collect(
     coll,
     {
     Col1: First(temp).Result,
     Col2: Last(FirstN(temp, 2)).Result,
     Col3: Last(temp).Result
     });
    ClearCollect(temp, Split(s2, ","));
    Collect(
     coll,
     {
     Col1: First(temp).Result,
     Col2: Last(FirstN(temp, 2)).Result,
     Col3: Last(temp).Result
     });
    ClearCollect(temp, Split(s3, ","));
    Collect(
     coll,
     {
     Col1: First(temp).Result,
     Col2: Last(FirstN(temp, 2)).Result,
     Col3: Last(temp).Result
     })

    Another alternative is to use a ForAll loop to do it for all the values that you have:

    Clear(coll2);
    ForAll(
     [s1, s2, s3],
     Collect(
     coll2,
     {
     Col1: First(Split(Value, ",")).Result,
     Col2: Last(FirstN(Split(Value, ","), 2)).Result,
     Col3: Last(Split(Value, ",")).Result
     })
    )

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!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410 Super User 2025 Season 2

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 2

Loading started