Left, Mid and Right Powerapps function

The Left, Mid, and Right functions in powerapps are used to extract the specified number of characters from the string, or from a single column of table.

1. Single String
If we specify a single string as an argument, the function returns the portion that we requested of the string.

A. Left Function
The Left functions returns the beginning characters of a string.

Note: The first character is starts from the position 1.

Power Apps Syntax Left(String, NumberOfCharacters)
The function has the following required parameters:

B. Mid Function The Mid functions returns the middle characters of a string.

Note: The first character is starts from the position 1.

Power Apps Syntax Mid(String, StartingPosition [, NumberOfCharacters ] )

The function has the following required parameters:

C. Right Function
The Right functions returns the ending characters of a string.

Note: The first character is starts from the position 1.

Power Apps Syntax Right(String, NumberOfCharacters)
The function has the following required parameters:

Example: The examples in this section the Text label control is used as the data source.

Step 1: The Text label control is named Label1 and set its Text property to the string "Ashish Goel is a developer".

Left Mid and Right function in Canvas Power Apps

Step 2: Add another Text label control and set its Text property to the following powerapps formula:

Power Apps Formula

Left(Label1.Text,5)
//Label1 is the name of the control

The above formula extracts up to five characters from the start of the string.

Left Mid and Right function in Canvas Power Apps

Step 3: Add another Text label control and set its Text property to the following formula:

Power Apps Formula

Right(Label1.Text,5)
//Label1 is the name of the control

The above formula extracts up to five characters from the end of the string.

Left Mid and Right function in Canvas Power Apps

Step 4: Add another Text label control and set its Text property to the following formula:

Power Apps Formula

Mid(Label1.Text,5)
//Label1 is the name of the control

As in the above function, we don’t specify the number of characters so it returns all characters, starting with the fifth character, from the string.

Left Mid and Right function in Canvas Power Apps

Step 5: Add another Text label control and set its Text property to the following formula:

Power Apps Formula

Mid(Label1.Text,5, 15)
//Label1 is the name of the control

The above formula extracts total fifteen characters, starting with the fifth character, from the string.

Left Mid and Right function in Canvas Power Apps

Note:
If we request more characters than the string contains, the function returns as many characters as possible.

Step 6: Add another Text label control and set its Text property to the following formula:

Power Apps Formula

Left(Label1.Text,50)
//Label1 is the name of the control
Left Mid and Right function in Canvas Power Apps

2. Single Column Table
If we specify a single-column table that contains strings, the function returns a single-column table with a Value column containing the portions that we requested of those strings.

A. Left Function
The syntax of Left function to extract text from single column table is as follows.

Power Apps Syntax Left(SingleColumnTable, NumberOfCharacters)
The function has the following parameters:
• SingleColumnTable - Required. A single-column table of strings from which to extract the results.
• NumberOfCharacters - Required. The number of characters to return.

B. Mid Function
The syntax of Mid function to extract text from single column table is as follows.

Power Apps Syntax Mid(SingleColumnTable, StartingPosition [, NumberOfCharacters]
The function has the following parameters:
• SingleColumnTable - Required. A single-column table of strings from which to extract the results.
• StartingPosition - Required. The starting position. The first character of the string is position 1.
• NumberOfCharacters - Optional. The number of characters to return. If omitted for the Mid function, the function returns the portion from the starting position until the end of the string.

C. Right Function
The syntax of Right function to extract text from single column table is as follows.

Power Apps Syntax Right(SingleColumnTable, NumberOfCharacters)
The function has the following parameters:
• SingleColumnTable - Required. A single-column table of strings from which to extract the results.
• NumberOfCharacters - Required. The number of characters to return.

Example: We can use any table, for now we are using a sharepoint list as a data source. We have a list in sharepoint called “My Users List”.

Left Mid and Right function in Canvas Power Apps

Step 1: Add this Data source in the Power Apps.

Left Mid and Right function in Canvas Power Apps

Step 2: Add a Drop down control and set its Items property to the following formula.

Power Apps Formula

Left( ShowColumns( 'My Users List', "field_1" ), 5 )

The above formula extracts the first five characters of each string. And returns a single column table with a Value column contained the extracted values.

Left Mid and Right function in Canvas Power Apps

We can see the values in the drop down control.

Left Mid and Right function in Canvas Power Apps

Similarly, we can implement Mid and Right functions for single column table.

Note: If the starting position is negative or beyond the end of the string, Mid returns blank. We can check the length of a string by using the Len function.