Search code examples
powerappspowerapps-canvaspowerapps-formula

Split Text in Powerapps


I have a TextInput1 on my Powerapps, I want to split the text in that textbox and save each individual value as a variable in memory

I used following code in the items property of comboBox, The following code return the split text as a table datatype so, it works on combobox but I couldn't figure out how to save the values individually in memory like var1, var2 and so on.

Split( TextInput1.Text, " " )


Solution

  • If you know exactly how many parts the string would have you can use the Index function to take the items that were returned, something like this:

    With(
        { parts: Split(TextInput1.Text, " ") },
        UpdateContext( {
            var1: Index(parts, 1).Value,
            var2: Index(parts, 2).Value,
            var3: Index(parts, 3).Value
        } ))
    

    If you don't know, you can store the result in a collection - and this collection can be used in controls such as a gallery or combo boxes, for example:

    ClearCollect( parts, Split( TextInput1.Text, " " ) )
    

    Or

    Set( parts, Split( TextInput1.Text, " " ) )