Hi,
I want to split a string from label and store it in a collection, i also want to add indexes to splitted text.
Example:
My label("Resulting_Text"is the name of the label) looks like this "E123a E143b E156f". I want my collection to have 2 columns("Index" and "Value" are the names of the columns).
Collection should look like this:
Index Value
0 E123a
1 E143b
2 E156f
Pls help
Thank you
@timl If I use your formula as-is (or changing to my label control) it presents the error:
The function 'AddColumns' has some invalid arguments
Any thoughts why this might be the case?
That's the part that retrieves the value (eg, E123a). The Split function splits the input into rows so the call to index is required to retrieve the corresponding value by ordinal number.
Hi @timl , I don't understand what does the last part of the AddColumns() function do?
Index( data, Index ).Result
You're welcome @Anonymous - glad to help!
@Anonymous
Here's a formula to do this:
ClearCollect(
yourCollection,
With(
{
data: Split(
"E123a E143b E156f",
" "
)
},
AddColumns(
RenameColumns(
Sequence(CountRows(data)),
"Value",
"Index"
),
"Value",
Index(
data,
Index
).Result
)
)
)
With the formula above, you would substitute the hardcoded value "E123a E143b E156f" with a reference to your label control (eg label1.Text).
If you want a collection try looking at this thread:
https://powerusers.microsoft.com/t5/Building-Power-Apps/split-string-into-collection/td-p/764556
Is there any reason you need a collection?
You can create records with the help of a varabile:
WarrenBelz
637
Most Valuable Professional
stampcoin
570
Super User 2025 Season 2
Power Apps 1919
473