cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
agneum
Advocate V
Advocate V

Check if item exists in list of values


I'm looking for a fuction to replace the following psuedocode:

Exists(Textbox1.Text;
DropDown.Items)


//Returns true if textbox1.text is in the list of dropdown items.

EDIT: Made an edit to make the problem easier to explain.


 

18 REPLIES 18

Hi @agneum ,

I misunderstood your question - I will leave you with @eka24 

@WarrenBelz  I was just very unclear. What I could do is turn the list of countries into a collection and use the Filter + Count methods on it to determine if it's in the list. But was hoping I could use another control (and its items property where I have all the values it could have defined) as the source of the list to check against instead, if that makes sense.

I couldn't use dropdown.items as a datasource, so I suspect it's not possible to do.


Thanks for your help!

 

Hi @agneum ,

I also should have seen your level and realised you would have thought of the solution I posted.

I think you are on the right track.

If the idea is to limit calls to your database, create a collection and then use the collection as the dropdown list :

 

ClearCollect( Countries,    { City: "London",    Country: "United Kingdom"},    { City: "Berlin",    Country: "Germany"},    { City: "Madrid",    Country: "Spain"},    { City: "Hamburg",   Country: "Germany"},    { City: "Barcelona", Country: "Spain"},    { City: "Munich",    Country: "Germany"})

OR

ClearCollect (Countries,YourTableName) The use Countries as a list for the dropdown

 

Adding screen shot may help clarify issues.

Seems like a collection is the way to go. But since the dropdown is a lookup on a static table, it would be nice to somehow specify "this is the list of values this dropdown can be" directly in the property. 

 

Is that you want a massage to be Shown?
If you can explain further.
brianng2
Frequent Visitor

I have a table named "Programs" in a SQL server db and it is the datasource for a Listbox in PowerApps Canvas.

The listbox is an multi-select one and I was successful to save the select Program ID into the database under a concatenated string (for example: 538,539 - where 538 and 539 are the program ids and "," is the delimiter).

 

Now I want to retrieve the record and display it on a Detail screen but instead of IDs in the database, I want to display the Program's names. If there is one program selected, I know I can use the following code

 

Filter('[dbo].[ProgramCodes]', ProgramID = ThisItem.ProgramID).ProgramName

 

but the issue is this listbox is the multi-select one and I can have more than 1 program selected. How can I do that?

Also tried: Filter('[dbo].[ProgramCodes]', ProgramID in Split(ThisItem.ProgramID, ",")).ProgramName but didn't work.

@brianng2 ,

This is an old closed thread, can you please create a new one with your query.

NadiaTruman
New Member

If("Text" in DataCardValue.Selected.Value, true,false)

OR
If("Text" in Concat(ComboBox1.SelectedItems, Value&","),true)

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (1,809)