Left, Mid, and Right functions in PowerApps

Extracts the left, middle, or right portion of a string of text.

Description

The Left, Mid, and Right functions return a portion of a string.

  • Left returns the beginning characters of a string.
  • Mid returns the middle characters of a string.
  • Right returns the ending characters of a string.

If you specify a single string as an argument, the function returns the portion that you requested of the string. If you specify a single-column table that contains strings, the function returns a single-column table of the portions that you requested of those strings. If you specify a multi-column table, you can shape it into a single-column table, as working with tables describes.

If the starting position is negative or beyond the end of the string, Mid returns blank. You can check the length of a string by using the Len function. If you request more characters than the string contains, the function returns as many characters as possible.

Syntax

Left( String, NumberOfCharacters )
Mid( String, StartingPosition, NumberOfCharacters )
Right( String, NumberOfCharacters )

  • String - Required. The string to from which to extract the result.
  • StartingPosition - Required (Mid only). The starting position. The first character of the string is position 1.
  • NumberOfCharacters - Required. The number of characters to return.

Left( SingleColumnTable, NumberOfCharacters )
Mid( SingleColumnTable, StartingPosition, NumberOfCharacters )
Right( SingleColumnTable, NumberOfCharacters )

  • SingleColumnTable - Required. A single-column table of strings from which to extract the results.
  • StartingPosition - Required (Mid only). The starting position. The first character of the string is position 1.
  • NumberOfCharacters - Required. The number of characters to return.

Examples

Single string

The examples in this section use a text-input control as their data source. The control is named Author and contains the string "E. E. Cummings".

Formula Description Result
Left( Author.Text, 5 ) Extracts up to five characters from the start of the string. "E. E."
Mid( Author.Text, 7, 4 ) Extracts up to four characters, starting with the seventh character, from the string. "Cumm"
Right( Author.Text, 5 ) Extracts up to five characters from the end of the string. "mings"

Single-column table

Each example in this section extracts strings from the Address column of this data source, named People, and returns a single-column table that contains the results:

Formula Description Result
Left( ShowColumns( People, "Address" ), 8 ) Extracts the first eight characters of each string.
Mid( ShowColumns( People, "Address" ), 5, 7 ) Extracts the middle seven characters of each string, starting with the fifth character.
Right( ShowColumns( People, "Address" ), 7 ) Extracts the last seven characters of each string.

Step-by-step example

  1. Import or create a collection named Inventory, and show it in a gallery, as the first procedure in Show images and text in a gallery describes.
  2. Set the Text property of the lower label in the gallery to this function:

    Right(ThisItem.ProductName, 3)

    The label shows the last three characters of each product name.