Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Filtering the list of cities based on the selected country/region is a powerful way to simplify form interactions and improve data accuracy. Instead of overwhelming users with long, irrelevant dropdowns, this approach ensures they only see city options that match their chosen country/region—making the form faster to complete and easier to understand. This is especially valuable in scenarios like lead routing, where selecting the correct location ensures submissions reach the right team. In this guide, you learn how to set up this filtering using lookup fields and relationships between data tables.
The filtered lookup fields feature is available for marketing and event registration forms.
Set up filtered lookup fields
Set up filtered lookup fields in your form, like showing only cities that match the selected country/region, by following these steps. Each step is explained in detail later in this article.
- Create a new solution to organize all related components (custom tables, relationships, forms, views, and scripts) in one place. This approach makes it easier to manage, deploy, and maintain your work.
- Create custom entities for country/region and city because the default fields (
address1_countryandaddress1_city) are simple text fields and can't support filtering. Establish a relationship between the country/region and city entities. This relationship lets filtering work. - Populate the country/region and city entities with relevant data so lookup options are meaningful.
- Link the custom country/region and city entities to contact or lead entities so you can use them in forms.
- Add read permission for the Marketing Services User Extensible Role so it can access the country/region and city entities.
- Create a new marketing form and add country/region and city fields.
After you finish these steps, the new country/region and city fields appear in the form editor as lookup fields, letting you use dynamic filtering.
1. Create a new solution
- Go to Power Apps.
- Navigate to Solutions in the left-hand menu.
- Select +New Solution.
- Enter a name (for example,
LocationLookupFiltering), publisher, and version. - Select Create.
Once your solution is created, you can add all the components from the following steps (custom entities, relationships, form customizations, and filtering logic) into the solution for better structure and portability.
Tip
Learn more about the benefits of using solutions for customizations and understand how to create them: Create a solution.
2. Create custom entities for country/region and city and establish a relationship
- In your solution in Power Apps, select +New and select Table.
- You can import XLSX files with the list of countries/regions to simplify the process or you can build the table from scratch.
- Name the table Country/region.
- Add a primary column (for example, "Country/region Name") of type Text.
- Optionally, add other columns like "Country/region Code" or "Region" if needed.
- Create another table named City.
- Add a primary column (for example, "City Name") of type Text.
- Add a lookup column that references the Country/region table. This step creates the relationship needed for filtering.
- Select Save and exit to publish the tables.
Tip
Learn more about creating custom tables in Power Apps: Create and edit tables using Power Apps.
3. Populate the city and country/region entities with data
- Use Excel import, Power Automate, or manual entry in Power Apps to add records to both tables.
- Make sure each city record links to the correct country/region using the lookup field.
Tip
Learn more about the various ways to import data: Import data from Excel and export data to CSV.
4. Link custom country/region and city entities to contact or lead entities
To use your new country/region and city lookup fields in forms for contact or lead records, establish relationships between the entities.
- Add lookup fields to contact or lead
- In your solution in Power Apps, select Add existing Table to add the contact or lead table to your solution.
- Navigate to the Columns section and select +Add Column.
- Choose data type Lookup.
- For the Related Table, select Country/region.
- Name the column (for example, "Preferred Country/region" or "Country/region").
- Repeat the process to add a "City" lookup column. Select "City" as the related table.
- Save and publish: After you add both lookup columns, select Save and exit, then select Publish All Customizations to make the changes available in the form editor.
Tip
Enable the country/region lookups for the combined Lead & Contact audience by creating a mapping between Contact > Country/region and Lead > Country/region. The same applies for city lookup. Learn more about mapping: Lead-Contact Mapping.
5. Add read permission for the service user
To make sure users visiting your form can see the options in the country/region and city lookup fields, grant read access to the entities through the appropriate security role.
- Go to the Power Platform admin center.
- Go to Manage > Environments.
- Select the environment where your form and entities are located.
- Go to Settings > Users + Permissions > Security Roles.
- Find and open the Marketing Services User Extensible Role.
- Locate the "Country/region" and "City" entities (your custom tables).
- Set the Read permission to Organization level for both entities.
- Select Save to apply the changes.
Learn more about security roles in Security roles and privileges.
6. Create a new marketing form
- Create a new marketing or event registration form.
- The "Country/region" and "City" fields are now available in the list of fields in the right pane.
- Add "Country/region" and "City" lookup fields to your form. Make sure both lookup fields are properly configured.
- Select the City field and use the Filter values button to set up the filtering.
- In the filtering configuration window, select Country/region as the field for Based on answer to—this choice sets which lookup field acts as the filter input. Then, select Country/region under Show values for to specify the relationship that connects the Country/region and City entities and lets the filtering logic work.
- Publish and test your form.
You're done setting up! Your form now shows users only the most relevant options based on their selections. This approach improves data quality, reduces errors, and makes the form faster and easier to complete. You're ready to deliver a professional, user-friendly solution that helps customer satisfaction and operational efficiency.