Reputation: 1
I have a table in Power Apps with multiple columns of location data. Screenshot below is an example from an Excel file, formatted the same way. I want to have three ComboBoxes (Country, State/Province, and City), each showing only distinct values and with the selection of the first filtering the available options of the next level down.
The Country ComboBox should only show two rows - United States and Canada, not one for each entry in the dataset. This is working correctly, and here is the code I have in the Items propety:
Sort(Distinct('Dim Table Locations', Country),Value,SortOrder.Ascending)
As an example - If I select Canada from the Country ComboBox, the State/Province ComboBox should then show one entry each for Ontario, Alberta, and British Columbia. But when I make a selection in the Country ComboBox, the State/Province ComboBox is blank. Here is the code I have for State/Province:
Filter(Sort(Distinct('Dim Table Locations', State/Province),Value,SortOrder.Ascending), Value = Combo_Country.Selected.Value)
Could anyone please help with resolving this?
Upvotes: 0
Views: 1441
Reputation: 155
Edited: Please try the below and if you still face the issue, please revert to the screenshots next time for my better understanding:
Combobox1 items
SortByColumns(
Distinct(
'Dim Table Locations',
Country
),
"Value",
SortOrder.Ascending
)
Combobox2 items
SortByColumns(
Distinct(
Filter(
'Dim Table Locations',
Country = Combobox1.Selected.Value
),
'State/Provice'
),
"Value",
SortOrder.Ascending
)
Combobox3 items
SortByColumns(
Distinct(
Filter(
'Dim Table Locations',
Country = Combobox1.Selected.Value,
'State/Provice' = Combobox2.Selected.Value
),
City
),
"Value",
SortOrder.Ascending
)
Upvotes: 0
Reputation: 1
I was able to get this working by switching from ComboBoxes to DropDowns. Here's the code I used for Country:
Sort(Distinct('Dim Table Locations', Country),Value,SortOrder.Ascending)
And here is the code I used for State/Provice:
Sort(Distinct(Filter('Dim Table Locations', Country=Dropdown_Country.Selected.Value),State/Province),Value,SortOrder.Ascending)
Upvotes: 0