cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Babalaul
Level: Powered On

Filter dropdown choices based on a number

Hi guys,

 

I have this text data card where i input numbers and a dropdown menu with cities. I would like to make the dropdown choices available based on the number that i type in. 

The numbers will always have the same format, 10 digits and in the middle, the city code. The other digits will be random.

1232065231 - New York,Baltimore, Boston

1233085345 - Los Angeles, San Francisco

 

Purpose of this is that i would like to restrict users when they input a number. to select the wrong city. 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
tchin-nin
Level 10

Re: Filter dropdown choices based on a number

Hi @Babalaul

 

I would use a table like @PK_Hong is suggesting.

Maybe like :

ClearCollect(citytable,

{Citycode:"065",cityname:"New York"},

{Citycode:"065",cityname:"Baltimore"},

{Citycode:"065",cityname:"Boston"},

{Citycode:"085",cityname:"Los Angeles"},

{Citycode:"085",cityname:"San Francisco"}

)

 

And if you want to extract the city number from a larger textInput, I would use the Mid() function :

 

Dropdownlist.Items : Filter(citytable,Citynumber=Mid(TextInput.Text,5,3) )

 

Théo

tchin-nin
Level 10

Re: Filter dropdown choices based on a number

Try setting the DataCard.Update to :

 

{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
   Id:0,
  Value : DropDownList.Selected.Value}

 

SharePoint is expecting this kind of object in it's Choice column.

 

So this is the kind of oject that is going to be stored and retrieve to PowerApps as the default value of the drop-down when you'll try to update your Item.

I think that you'll need to change the default value of the DataCard to match your Excel table items :

 

Dropdownlist.default:

LookUp(dropdownDataSource,Value=ThisItem.ChoiceColumn.Value)

 

Théo

8 REPLIES 8
PK_Hong
Level 8

Re: Filter dropdown choices based on a number

Hi @Babalaul

 

You need to have a table such as below:

TableCity

Code    City

065       New York, Baltimore, Boston

085       Los Angeles, San Francisco

etc.

 

TextInput1 = (to ente code)

Dropdown shall be = Distinct(TableCity, LookUp(TableCity, TextInput1.Text = Code).City)

 

example:

TextInput1 bxox - 065

Distinct will filter TableCity where the entered code match the code in TableCity, and then show the matching CITY

 

Wish my wild guess is correct.

Have a nice day.

 

tchin-nin
Level 10

Re: Filter dropdown choices based on a number

Hi @Babalaul

 

I would use a table like @PK_Hong is suggesting.

Maybe like :

ClearCollect(citytable,

{Citycode:"065",cityname:"New York"},

{Citycode:"065",cityname:"Baltimore"},

{Citycode:"065",cityname:"Boston"},

{Citycode:"085",cityname:"Los Angeles"},

{Citycode:"085",cityname:"San Francisco"}

)

 

And if you want to extract the city number from a larger textInput, I would use the Mid() function :

 

Dropdownlist.Items : Filter(citytable,Citynumber=Mid(TextInput.Text,5,3) )

 

Théo

Babalaul
Level: Powered On

Re: Filter dropdown choices based on a number

Thank you. It worked.

Babalaul
Level: Powered On

Re: Filter dropdown choices based on a number

I realized that after i choose my value from the dropdown menu and click save, is not really saving it in my SharePoint list. Is blank. Any ideas please ? 

tchin-nin
Level 10

Re: Filter dropdown choices based on a number

Hi

What Column type is it un SharePoint ?
What is thé Update Property of your DataCard ?
How do you save the Form ?

Théo
Babalaul
Level: Powered On

Re: Filter dropdown choices based on a number

Hello,

 

In SharePoint is a "Choice column" , with the same city names that i have inputed in my excel table.

Update Property = Datacard.Selected

The way i submit the form is trough a save button , wich has on select = submit(form)

tchin-nin
Level 10

Re: Filter dropdown choices based on a number

Try setting the DataCard.Update to :

 

{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
   Id:0,
  Value : DropDownList.Selected.Value}

 

SharePoint is expecting this kind of object in it's Choice column.

 

So this is the kind of oject that is going to be stored and retrieve to PowerApps as the default value of the drop-down when you'll try to update your Item.

I think that you'll need to change the default value of the DataCard to match your Excel table items :

 

Dropdownlist.default:

LookUp(dropdownDataSource,Value=ThisItem.ChoiceColumn.Value)

 

Théo

Babalaul
Level: Powered On

Re: Filter dropdown choices based on a number

Actually it was much easier that i tought. I removed the dropdown menu and created a new one. Insrted the formula, connect it to the datacard and it works. Now it saves in my Sharepoint list.

 

Thanks

Helpful resources

Announcements
firstImage

PowerApps Monthly Community Call!

Join us next Wednesday for our Demo Extravaganza, October 16, 2019 8am PDT.

firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 268 members 5,170 guests
Please welcome our newest community members: