Mastering PowerApps Convert Dropdown Selected Value to Text for US States

Mastering PowerApps: Convert Dropdown Selected Value to Text for US States

Navigating the intricacies of PowerApps can be challenging, especially when striving for user-friendly data entry methods. One such method revolves around using dropdown menus for selections, such as selecting a US state. This guide delves deep into the transformation of “powerapps dropdown selected value to text” with a focus on US states.

Creating User-Friendly Address Entry

Address inputs frequently demand a dropdown option to select US states. This ensures accuracy and consistency. In this guide, we illustrate this setup process and further introduce the utilization of dropdown controls with key-description pairings. While this post uses an Excel dataset, you can easily replicate the process with other data sources like SharePoint lists.

Foundation: Setting Up Data Source

Our tutorial assumes you either have an autogenerated app derived from your dataset or an edit form added to an existing application.

Centralizing State Data

Apps often reference state codes and their respective descriptions. For efficiency, it’s wise to store such data in a central collection. Upon app startup, this collection can be initialized using the formula showcased below. Remember, this initialization must be triggered in design mode by right-clicking and selecting the ‘Run OnStart menu item‘.

ClearCollect(
    stateCollection,
    {Abbrev:"AL", FullName:"Alabama"},
    ...
    {Abbrev:"WY", FullName:"Wyoming"}
)
        

Note: The ellipsis (…) signifies the continuation of the pattern for all states.

Reference: Collect, Clear, and ClearCollect functions

Integrating a State Dropdown in Edit Forms

To enhance an edit form with a dropdown menu for states:

  1. Select ‘edit fields‘ and change the control type to ‘Allowed Values‘.
  2. Unlock the state card by right-clicking and opting for ‘unlock’.
  3. Direct the Item’s property towards our state collection, i.e., stateCollection.
  4. For saving the 2-character state abbreviation, adjust the Update property to reflect DropDownControl.Selected.Abbrev.
  5. Modify the dropdown control’s Value property to display the complete state name using FullName.
  6. To present the accurate value when the form pre-loads an old record, adjust the Default property with the formula:
    LookUp(stateCollection, 
           Abbrev=Parent.Default).FullName
                    

REFERENCE: LookUp functions

Conclusion

Dropdown menus, particularly for address inputs, amplify usability and accuracy. Through this guide, we explored the intricacies of establishing such a dropdown menu in PowerApps, especially for selecting US states. Configuring dropdown controls with key-description combinations further enriches the user experience. Need more guidance or have other technical inquiries? Do not hesitate to contact us for expert assistance.

About The Author