Len

Len

How to Use the Power Fx Len  Function in Power Apps

What is the Len Function?

The Len function in Power Fx is a tool that allows users to find the length of text strings. The syntax for the Len function is simple: `Len(❰text❱)`. The text argument is the string that you want to find the length of. The Len function returns the number of characters in the text string. It is a useful tool for developers who need to work with text strings regularly.

How to Use the Len Function in Power Fx

Using the Len function in Power Fx is straightforward. Let’s take a look at an example. Suppose you have a text input control in your Power App, and you want to find the length of the text entered by the user. Here is how you can use the Len function to achieve this:

1. First, create a text input control on your form. You can do this by clicking on the ‘Insert’ tab in the ribbon and selecting the ‘Text input’ control from the ‘Input’ group.

2. Next, add a label control to your form. This label control will display the length of the text entered by the user.

3. Now, select the label control and go to the ‘Properties’ pane. Under the ‘Text’ property, enter the following formula: `Len(TextInput1.Text)`. This formula will use the Len function to find the length of the text entered in the TextInput1 control.

4. Finally, preview your form, and you will see the length of the text entered by the user displayed in the label control.

Using the Len Function in Formulas

The Len function is also useful for working with text strings in formulas. Let’s take a look at an example. Suppose you have a table in your Power App that contains a column called ‘Name.’ You want to create a formula that calculates the average length of the names in the table. Here is how you can achieve this using the Len function:

1. First, create a new label control on your form. This label control will display the average length of the names in the table.

2. Next, select the label control and go to the ‘Properties’ pane. Under the ‘Text’ property, enter the following formula: `Average(Table1, Len(Name))`. This formula will use the Len function to find the length of each name in the ‘Name’ column of the ‘Table1’ table and then calculate the average length of all the names.

3. Finally, preview your form, and you will see the average length of the names displayed in the label control.

The Len function in Power Fx is a powerful tool that allows developers to work with text strings easily. In this article, we have learned how to use the Len function in Power Apps to find the length of text strings in text input controls and formulas. By using the Len function, developers can create more powerful and efficient applications with Power Apps.

Power Apps Training Courses by G Com Solutions (0800 998 9248)