Setting the default value in the Power Apps Modern Radio button is quite tricky compared to the classic one. In the classic radio control, we use the Default property to set the default value, whereas in the modern radio control, there is only one property called DefaultSelectedItems.
In this article, we will see how to set default value in Power Apps modern Radio button control manually and as well as from a SharePoint list.
Set Default Value in Power Apps Modern Radio Button Control
Let’s discuss some examples of how to achieve it.
Set Default Value in Power Apps Modern Radio Control Manually
Below is a Power Apps Modern Radio control with some products like Laptop, Mobile, Tablet, etc. (added manually).
Items = ["Laptop", "Mobile", "Tablet", "Desktop", "Mouse"]
Next, go to Properties pane -> Display -> Edit from Fields section -> + Add field -> Select Value -> Add.
Now, I want to set the default value of the modern radio button as Mobile. So that whenever a user opens the app, the default value should be set to Mobile.
As there is only one property to set the default value of the modern radio control, so go to the DefaultSelectedItems property and apply the code below:
DefaultSelectedItems = {Value: "Mobile"}
Where,
“Mobile” = Specify the item you want to set as default enclosed with the inverted comma.
Also, there is another way to set the default value of the modern radio control, i.e., without using the Value() function.
DefaultSelectedItems = ["Mobile"]
Finally, save, publish, and close the app. Once you play the app, you can see the Power Apps radio button default value has been set to Mobile, as shown below.
This is how to set the default value manually in a Power Apps Modern Radio control.
Set Default Value in Power Apps Modern Radio Control From a SharePoint List
Let’s discuss setting the default value in a Power Apps radio control from a SharePoint Choice column.
1. The below SharePoint list [IT Service Ticket] contains various columns with different data types. Among them is a choice field called a Department that includes multiple departments like IT, HR, FINANCE, SALES, etc. I want to set the default value as FINANCE in a Power Apps modern radio control.
2. You can see a modern Power Apps form that contains all the SharePoint fields. By default, the Department values appear in a Modern Combobox control whereas its Items property as.
Items = Choices([@'IT Service Ticket'].'Department')
But I want to convert it into a modern radio control and set the default value to FINANCE. To do so, I will copy this Combobox Item’s property code and make this control’s Visible property false.
Next, inside the same Department data card, insert a Modern Radio button and Paste the above code that you have copied [on its Items property] as:
Items = Choices([@'IT Service Ticket'].'Department')
3. By default, the radio button will appear in a horizontal layout. To make it a vertical design, go to its Layout property and apply the code below:
'RadioGroupCanvas.Layout'.Horizontal
You can also design your radio button using various styles and theme properties (like Font, Font size, Color, etc.) from the Properties pane.
4. Next, go to Properties pane -> Display -> Edit from Fields section -> + Add field -> Select Value -> Add. To make the radio button default value, go to the DefaultSelectedItems property and apply the code below:
DefaultSelectedItems = {Value: "FINANCE"}
Make sure you need to provide the exact value that you want to make it default. That’s why I have given the exact department name as FINANCE. If you provide any wrong value, it’ll create and add another choice value to the modern radio control.
5. Finally, we need to update the value of the Department datacard as shown below:
Update = RadioGroupCanvas2.Selected
Where,
RadioGroupCanvas2 = Modern Radio Control name
6. To save the Power Apps form in the SharePoint list, add a Save button and write the code below on its OnSelect property as:
OnSelect = SubmitForm(Form2); NewForm(Form2);
Form2 = Power Apps Edit Form Name
7. Save, Publish, and Preview the app. Fill in the form details (including the Department) and click the Save button.
Go to the SharePoint list and refresh it. The item has been added with the default radio choice value (FINANCE), as shown in the image below.
I hope this article finds you very helpful in learning this as nowhere has specified this thing till now. So, I tried it in my way and thought to share it with you.
This way, we can manually set the default value in the Power Apps modern radio button control and from the SharePoint list with different examples.
Additionally, you may like some more Power Apps tutorials:
- Power Apps Canvas App Dashboard
- Replace Current User Email With Anonymous Email in Power Apps
- Dynamically Display Image in Power Apps
- Show/Hide Button Based on Condition in Power Apps
- Concatenate Power Apps Combo Box Value With a Custom Value
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com