Unique Table Values

Hey, I want to build filters that filter based on values from the table. In this case I want one option to filter by to be "Rücken (Back)". But with {{ item.value }} it displays Rücken multiple times as an selectable option since it goes through every row and uses the value. Can I somehow make it so that it only shows evry value once?

(And yes I know theres a filter component, but I need the filters to be in German and so I need to build them myself)

Thanks for any help!! :blush:

Hi @KungFooLemmi,

Yes, it's definitely possible. Just to make sure I don't misguide you. What is the data source for your select component?

You could use a lodash function _. uniq or uniqBy, e.g. _.uniq(item.value).

Hey @MiguelOrtiz, the data source is a normal retool db or more specifically a two or mulltiple db joint via sql

Would you mind sending a screenshot of how your select component is set up?

.-uniq may or may nor work depending on your data source. But from what I see you have an id and Indikationsbereich, so by mapping your options to

value = {{item.id}}
label = {{item.indikationsbereich}} (or whatever your field is named)

retool may automatically identify duplicate values within your id and remove them.

By using these two it gives me the result from the og picture. Repeating each Value even if its the same

Thanks @KungFooLemmi, maybe try using your query's data source, rather than the table itself.

@MiguelOrtiz Isn't that the same?

HI @KungFooLemmi, in theory yes, but you could enter a dependency cycle.

Hover over data source and click on FX and try adding {{_.uniq(HanseMerkurTable.data)}} as your data source. If that doesn't work then my suggestion would be to create another query which pulls uniq Ids + names for the same data and use that as data source for your select component.

image
This is what i get then

Hey there,

Sorry I've been confused the whole time. Also didn't realize that retools DB appears with a table logo and that confused me.

Try putting item.indication in both value AND label (assuming indication doesnt' have a correlated id).

1 Like

You'll want to extract the value from the field before using _.uniq

_.uniq(HanseMerkurTabelle.data.map(x=>x.indikationsbereich))

Now you have a flat, unique array that you can use for value and label in your menu.

1 Like

@MiguelOrtiz I cant believe that was it :sweat_smile: Thanks so much for your help!

1 Like

Didnt need to try but thanks for the input!