Drowdown/Select with duplicate values but unique labels

I have a dropdown for locations with the zip code as values. Some locations can have the same zip code but the location names are unique.

For example:


However when I have duplicate values I get this error:

What's the best way to implement a dropdown with unique labels and allow duplicate values?

Hi @BernhardLenz,

That's an odd forced-validation from Retool, but there are definitely work-arounds.

You could use unique values (like the index) for each option, and then hold a lookup table elsewhere that matches the label to the final value you want to access, or you could keep an array of "correct" values in the same order, and pick it off that way. The "best" implementation probably depends on what you need to do with the data - is it part of a query, an API call, etc., where/when/how you're accessing the data will determine the easiest way to modify / reshape it.

1 Like

@MikeCB has some good suggestions. I’ve previously used a concatenation of the value and label as the “value” and then just pulled it apart when I used it in subsequent code. In your case, it’s an easy substring of 5 characters…a bit annoying, but workable.

1 Like