How to Set Default Selected Item in Power Apps Gallery?

Do you know how to set a default selected item in a Power Apps gallery? This Power Apps tutorial will explain all the information about the Power Apps Gallery default selected Item.

Here, we will discuss how to set the Power Apps gallery default first item and Power Apps gallery default selection none or Power Apps gallery remove a default selection.

Set Default Selected Item in Power Apps Gallery

Let’s see how to set a default selected item in the Power Apps gallery using two ways. Such as:

  1. How to Set Default Selected Item in Power Apps Gallery [Manually]
  2. Set Default Selected Item in Power Apps Gallery [From SharePoint List]

Set Default Selected Item in Power Apps Gallery Manually

For example, I have a Power Apps gallery control with items like “Power Apps”, Power BI, and Power Automate. Now, I want to set the gallery’s Default to one record that belongs to the gallery’s Items table.

powerapps gallery default selected item

To set the Default property of the Gallery control, you need to write the below code on the Gallery’s Default property:

Default = {Value:"Power BI"}
powerapps gallery control default selected item

When a user opens/runs an app, the gallery control will appear with the default deleted value [Power BI], as in the screenshot below.

how to set powerapps gallery default selected item

This is how to set a default selected item in the Power Apps gallery manually.

Set Default Selected Item in Power Apps Gallery from SharePoint List

Now, we will see how to set a default selected item in a Power Apps gallery from the SharePoint list with a simple scenario.

Scenario:

I have a SharePoint Online list, i.e., [Project Tracker] and this list contains the below fields.

Column NameData Type
Project NameDefault single line of text
DescriptionMultiple lines of text
Project StatusChoice
Start DateDate and time
End DateDate and time

Refer to the below screenshot:

how to set powerapps gallery control default selected item

In Power Apps, a gallery control has SharePoint choice field items. Now, I want to set its Default value as a “Completed” item only.

So when the user opens the app, he/she can always view the gallery will appear with the default value “Completed”. Also, the default value will appear with a different highlighted color, as shown below.

set gallery default selected value in power apps

To work around this, follow the below-mentioned steps. Such as:

1. Open Power Apps -> Create a Blank Canvas app and connect it to the respective SharePoint list -> Go to the Power Apps Screen -> Insert a Gallery control and set its Items property as:

Items = 'Project Tracker'

Where,

  • ‘Project Tracker’ = SharePoint Online List
gallery default selected item in power apps

2. Also, to display the SharePoint choice field [Project Status] items in the gallery, insert a Text label inside the gallery control and set its Text property as:

Text = ThisItem.'Project Status'.Value

Where,

  • ‘Project Status’ = SharePoint list choice field
gallery control default selected item in power apps

3. Next, select the Gallery control and set its Default property to the below code:

Default = LookUp(
    'Project Tracker',
    'Project Status'.Value = "Completed"
)

Where,

  • LookUp() = This function is used to find a single record that matches one or more criteria
  • ‘Project Status’.Value = “Completed” =This condition evaluates for rows in the specified input
powerapps gallery sharepoint list default selected item

4. At last, select the TemplateFill property of the gallery control and apply the below code:

TemplateFill = If(
    ThisItem.IsSelected,
    RGBA(
        34,
        139,                          //Color Code Of "Color.ForestGreen"
        34,
        1
    ),
    RGBA(
        250,
        240,                         //Color Code Of "Color.Linen"
        230,
        1
    )
)
powerapps gallery default selected item from sharepoint list

5. Save, Publish, and Close the app to view the result. When you reopen the app again, you will see the gallery appear with the default value “Completed” as in the screenshot below.

how to set gallery default selected value in power apps

This is how to set a default selected item in the Power Apps gallery from a SharePoint list.

Power Apps Gallery Default Selected First Item

This section will discuss how to set a Power Apps gallery default selected first item with a simple example.

Example:

I have a Power Apps gallery that has some items like “Power Apps”, “Power BI”, and “Power Automate”. Now, I want to set the default selected first item [Power Apps] in the Power Apps gallery with a different highlighted color, as in the screenshot below.

powerapps gallery default selected first item

To do so, follow the below steps.

1. Select a respective Power Apps Screen where you want to set the default value of a gallery control -> Set its OnVisible Property to the code below.

OnVisible = Set(
    varSelectFirstItem,
    First(gal_PowerPlatforms.AllItems)
)

Where,

  • varSelectFirstItem = Power Apps variable name
  • First() = This function returns the first record of a table
  • gal_PowerPlatforms = Power Apps gallery control name
powerapps gallery control default selected first item

2. Now, select the Gallery control and set its TemplateFill property as:

TemplateFill = If(
    ThisItem.IsSelected,
    Color.LightGreen,
    Color.White
)
how to set powerapps gallery default selected first item

3. Save, Publish, Reload, and Preview the app. The gallery will appear with the first selected item with the respective color, as shown below.

gallery default selected first item in powerapps

This is how to set a default selected first item in the Power Apps gallery control.

Power Apps Gallery Default Selection None

Lastly, I will show you how to set the Power Apps gallery default selection to none until an item has been selected.

Let’s take a simple scenario: I will also take the above SharePoint Online list [Project Tracker], and In Power Apps, there is a gallery control that contains the “Project Name” items. Whenever the user opens or runs an app, the gallery will appear with a default value.

Now, I would like to make a Power Apps gallery default selection is none until an item has been selected as shown below.

powerapps gallery default selection none

To achieve it, follow the below steps. Such as:

1. Insert a new blank screen [ProjectDetailsScreen] -> Add a Gallery control and set its Items property -> To retrieve the SharePoint list text field, insert a Text label and set its Text property as shown below.

Items = 'Project Tracker'

Text = ThisItem.Title
powerapps gallery control default selection none

2. Then, Select a Power Apps Screen and set its OnVisible property to the code below.

OnVisible = Reset(gal_ProjectsDetails)

Where,

  • Reset() = This function is used to reset a control to its ‘Default’ property value
  • gal_ProjectsDetails =Power Apps gallery name
powerapps gallery default selected item blank

3. Now, select a Gallery control and set its Default property as:

Default = {}
powerapps gallery control default selected item blank

4. Once your app is ready, Save, Publish, Reload, and Preview the app. The gallery will appear without any default selected item, as shown below.

gallery default selection none in powerapps

This is all about the Power Apps gallery default selection of none or the Power Apps gallery default selected item blank.

Conclusion

I hope this Power Apps tutorial explains in detail information about the set default selected item in the Power Apps gallery, including:

  • Set Default Selected Item in Power Apps Gallery Manually
  • Set Default Selected Item in Power Apps Gallery from SharePoint List
  • Power Apps Gallery Default Selected First Item
  • Power Apps Gallery Default Selection None

You may also like:

>