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
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
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?
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:
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
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.
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
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 }) )
WarrenBelz
791
Most Valuable Professional
MS.Ragavendar
410
Super User 2025 Season 2
mmbr1606
275
Super User 2025 Season 2