Choices

How to Use the Power Fx Choices  Function in Power Apps

Understanding the Power Fx Choices Function

The Power Fx Choices function is a powerful function that allows you to create a list of choices that users can select from in your Power Apps application. This function can be used in a variety of scenarios, such as when you need to create a dropdown list of options or when you need to create a set of radio buttons that users can select from.

The syntax of the Power Fx Choices function is as follows:


Choices(choices, options)


The first parameter, `choices`, is an array of values that represent the choices that users can select from. The second parameter, `options`, is an optional record that allows you to specify additional options for the Choices function.

Using the Power Fx Choices Function in Power Apps

To use the Power Fx Choices function in Power Apps, you need to start by creating a new app or opening an existing one. Once you have your app open, you can start building your custom functionality using the Power Fx formula language.

To create a dropdown list using the Power Fx Choices function, follow these steps:

1. Add a dropdown control to your app by clicking on the “Insert” tab in the ribbon and selecting “Dropdown” from the “Controls” section.

2. Select the dropdown control on your app screen and open the “Properties” pane on the right-hand side of the screen.

3. In the “Items” property of the dropdown control, enter the following formula:


Choices(["Option 1", "Option 2", "Option 3"])


4. Save your changes and run your app. You should now see a dropdown list of options that users can select from.

To create a set of radio buttons using the Power Fx Choices function, follow these steps:

1. Add a radio button control to your app by clicking on the “Insert” tab in the ribbon and selecting “Radio” from the “Controls” section.

2. Select the radio button control on your app screen and open the “Properties” pane on the right-hand side of the screen.

3. In the “Items” property of the radio button control, enter the following formula:


Choices(["Option 1", "Option 2", "Option 3"], { DisplayMode: DisplayMode.Edit, Layout: Layout.Vertical })


4. Save your changes and run your app. You should now see a set of radio buttons that users can select from.

Additional Options for the Power Fx Choices Function

The Power Fx Choices function also allows you to specify additional options for your list of choices. Some of the most commonly used options include:

– `DisplayMode`: This option allows you to specify whether the control should be in “Edit” mode or “View” mode.

– `Layout`: This option allows you to specify the layout of the list of choices. You can choose between “Vertical” and “Horizontal” layouts.

– `DefaultValue`: This option allows you to specify a default value for the control.

– `AllowEmptySelection`: This option allows you to specify whether users can select no options in the list.

The Power Fx Choices function is a powerful feature in Power Apps that allows you to create custom dropdown lists and radio buttons that users can select from. By using the syntax and options discussed in this article, you can create complex sets of choices that meet the needs of your business applications. With the Power Fx formula language, the possibilities for custom functionality in Power Apps are endless.

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