SetProperty

How to Use the Power Fx SetProperty  Function in Power Apps

The SetProperty function is a powerful tool that allows you to set the value of a property for a control or data source in your application. It can be used to create dynamic and interactive applications that respond to user input in real-time. In this article, we will explore the various ways you can use the SetProperty function in Power Apps.

What is the SetProperty Function?

The SetProperty function is a function in Power Apps that allows you to set the value of a property for a control or data source in your application. It takes two parameters – the name of the property you want to set and the value you want to set it to. Here is an example of how to use the SetProperty function:


SetProperty(MyButton, Text, “Click me!”)


In this example, we are setting the Text property of a button control named MyButton to "Click me!".

Using the SetProperty Function with Controls

The SetProperty function can be used with any control in your Power Apps application. Here are some examples of how you can use it:

Setting the Text of a Label Control


SetProperty(MyLabel, Text, “Hello World!”)


In this example, we are setting the Text property of a label control named MyLabel to "Hello World!".

Setting the Visibility of a Button Control


SetProperty(MyButton, Visible, false)


In this example, we are setting the Visible property of a button control named MyButton to false, which will hide it from the user.

Setting the Color of a Rectangle Control


SetProperty(MyRectangle, Fill, RGBA(255, 0, 0, 1))


In this example, we are setting the Fill property of a rectangle control named MyRectangle to a solid red color.

Using the SetProperty Function with Data Sources

The SetProperty function can also be used with data sources in your Power Apps application. Here are some examples of how you can use it:

Setting the Default Value of a Text Input Control


SetProperty(MyTextInput, Default, First(MyDataSource).ColumnName)


In this example, we are setting the Default property of a text input control named MyTextInput to the value of the first column in a data source named MyDataSource.

Setting the Filter of a Gallery Control


SetProperty(MyGallery, Filter, MyDataSource.ColumnName = “Value”)


In this example, we are setting the Filter property of a gallery control named MyGallery to show only items where a column named ColumnName in a data source named MyDataSource equals "Value".

The SetProperty function is a powerful tool in Power Apps that allows you to set the value of a property for a control or data source in your application. It can be used to create dynamic and interactive applications that respond to user input in real-time. In this article, we explored the various ways you can use the SetProperty function with controls and data sources in your Power Apps application. With this knowledge, you can create highly customized and powerful applications that will impress your users.

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