Latest Posts

PowerApps Split string in substrings using delimiter


The Split function in PowerApps is used to divide a text string into a table of substrings based on a specified delimiter. This function is particularly useful when you need to parse and manipulate text data that is formatted in a specific way, such as CSV data, space-separated words, or other delimited text.

PowerApps – Split() function Syntax

 

Split(Text, Separator)

 

  • Text: The text string that you want to split.
  • Separator: The delimiter used to split the text string into substrings.

Notes:

  • Empty Strings: If the text string is empty, Split returns an empty table.
  • Missing Separator: If the separator is not found in the text string, the entire string is returned as a single value in the table.

PowerApps – Split() function basic example

Suppose you have a text string "Red,Green,Blue" and you want to split it into individual colors:

Split("Red,Green,Blue", ",")

This returns a table with the values Red, Green, and Blue.

PowerApps – Split string by space

If you have a sentence and you want to split it into individual words:

Split("PowerApps is amazing", " ")

This returns a table with the values PowerApps, is, and amazing.

PowerApps - Split a CSV Line

Suppose you have a CSV line and you want to split it into individual fields:

Split("John,Doe,30,Developer", ",")

This returns a table with the values John, Doe, 30, and Developer.

PowerApps - Extract Values from a URL Query String

If you have a URL with query parameters and you want to extract specific values:

// Assuming URL is "http://example.com?page=1&sort=asc"

Set(QueryString, "page=1&sort=asc");

Set(QueryParameters, Split(QueryString, "&"));

This splits the query string into individual parameters: page=1 and sort=asc.

PowerApps - Parse Multi-Select Values

If you have a multi-select control that returns a concatenated string of selected values and you want to split it into individual items:

Split(SelectedValues, ";")

This splits the selected values based on the semicolon delimiter.

PowerApps – Split() function example in an App

Suppose you have a text input control where users can enter comma-separated values, and you want to display these values in a gallery:

  1. Add a Text Input Control

Name the text input control TextInput1.

  1. Add a Button to Trigger the Split

Add a button control and set its OnSelect property to:

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

 

  1. Add a Gallery to Display the Split Values

Add a gallery control and set its Items property to:

SplitValues

Set the Text property of a label inside the gallery to:

ThisItem.Value

This will display each value from the comma-separated input in the gallery as individual items.


We value your Feedback:

Page URL:

Name:

Email:


Suggestion:

© 2024 Code SharePoint