Substitute

Substitute

How to Use the Power Fx Substitute  Function in Power Apps

What is the SUBSTITUTE Function?

The SUBSTITUTE function is a text function that replaces a specified text value with a different text value in a string. The syntax for the SUBSTITUTE function is as follows:


SUBSTITUTE(Text, OldText, NewText, [Instance])


Where:

- Text: This is the text string where the replacement will be performed.

- OldText: This is the text value that will be replaced.

- NewText: This is the new text value that will replace the old text value.

- Instance: This is an optional parameter that specifies which occurrence of the old text value to replace. If this parameter is not specified, all occurrences of the old text value will be replaced.

How to Use the SUBSTITUTE Function in Power Apps

To use the SUBSTITUTE function in Power Apps, follow these steps:

1. Open the Power Apps studio and create a new canvas app.

2. Add a Text input control to the app screen.

3. Add a Label control to the app screen and set its Text property to "Enter the text to replace".

4. Add a second Label control to the app screen and set its Text property to "Enter the new text".

5. Add a Button control to the app screen and set its Text property to "Replace Text".

6. Select the Button control and go to the Advanced tab of the Properties pane.

7. In the OnSelect property of the Button control, enter the following formula:


Set(replacedText, SUBSTITUTE(TextInput1.Text, Label1.Text, Label2.Text))


Where:

- TextInput1.Text: This is the text string where the replacement will be performed. You can change this to the name of your Text input control.

- Label1.Text: This is the text value that will be replaced. You can change this to the name of your first Label control.

- Label2.Text: This is the new text value that will replace the old text value. You can change this to the name of your second Label control.

- replacedText: This is a variable that will store the result of the SUBSTITUTE function.

8. Save the app and run it.

9. Enter some text in the Text input control.

10. Enter the text to be replaced in the first Label control.

11. Enter the new text in the second Label control.

12. Click on the Replace Text button.

13. The result of the SUBSTITUTE function will be displayed in a Label control.

The SUBSTITUTE function is a useful text function that allows users to replace text in a string with a different text value. With Power Fx, users can easily create custom functions and formulas for their Power Apps. By using the SUBSTITUTE function in Power Apps, users can improve the functionality and user experience of their applications.

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

Copyright, G Com Solutions Ltd, 2024.
Tower Bridge Business Centre, 46-48 East Smithfield, London E1W 1AW
0800 998 9248   |   9:00 a.m. till 5:30 p.m.

Connect With Me: