Populating Dropdowns - Best Practices?

When populating a dropdown box with values using a reference, is it best that each dropdown list be its own page in a "variables" spreadsheet, or is it okay to create a single page for variables with dropdown options in its own column?

Solved Solved
0 9 361
1 ACCEPTED SOLUTION

Steve
Platinum 4
Platinum 4

Neither of those approaches is "best". Instead, create a table called Options with three columns: a Key column, a Context column, and an Option column. The Context column identifies the context for which the row's Option column is valid. The Option column contains a valid option for the row's given Context value.

KeyContextOption
1namesBob
2namesSara
3namesMateo
4directionsNorth
5directionsEast
6directionsSouth
7directionsWest

To use the names options, for instance as Suggested values:

 

 

 

 

SORT(
  SELECT(
    Options[Option],
    ("names" = [Context]),
    TRUE
  )
)

 

 

 

 

To use directions options, perhaps in a Valid If:

 

 

 

 

SELECT(
  Options[Option],
  ("directions" = [Context]),
  TRUE
)

 

 

 

 

View solution in original post

9 REPLIES 9

Could you please explain your question further? maybe with examples? Thanks.

Screenshot 2022-02-28 09.26.07.png

 

Would this be okay, or should Dropdown 1, Dropdown 2, and Dropdown 3 be separate pages in the spreadsheet since the information in each row is not related to each other in any way?

Steve
Platinum 4
Platinum 4

Neither of those approaches is "best". Instead, create a table called Options with three columns: a Key column, a Context column, and an Option column. The Context column identifies the context for which the row's Option column is valid. The Option column contains a valid option for the row's given Context value.

KeyContextOption
1namesBob
2namesSara
3namesMateo
4directionsNorth
5directionsEast
6directionsSouth
7directionsWest

To use the names options, for instance as Suggested values:

 

 

 

 

SORT(
  SELECT(
    Options[Option],
    ("names" = [Context]),
    TRUE
  )
)

 

 

 

 

To use directions options, perhaps in a Valid If:

 

 

 

 

SELECT(
  Options[Option],
  ("directions" = [Context]),
  TRUE
)

 

 

 

 

I have much to learn ๐Ÿค”

Thank you

Hello Steve, 

A question please. Wouldn't creating separate tables allow us to avoid the use of SELECT? This is what I've been doing. If this approach is suboptimal I'll go back and change it. What do you think please? Thank you!

Sure, separate tables would eliminate the need to use SELECT(), which makes for simpler expressions and allows for dependent dropdowns. I don't like having all those extra worksheets, though. You could also use my single worksheet approach then use slices to separate the options within the app. I use this approach when the Options table gets large to improve efficiency.

Your approach is perfectly fine; it's a matter of preference.

If i may deviate for a moment, in your example, let's assume you have a long list of options for various things. How do you go about generating your key?

I like the idea of UNIQUEID() in appsheet, but i have also learned that if I manually populate a spreadsheet with information, AppSheet doesn't see that data if the column with the key is not populated in advance.

If I understand this correctly and am using the right words, AppSheet cannot retroactively populate a key with UNIQUEID(), the key field must be populated in advance in order for AppSheet to "see" the data. Is this correct? Also, using a formula is in a key field is not supported either, right?

I saw an article about using a spreadsheet formula to create values similar to how UNIQUEID() works, but since it doesn't like spreadsheet formulas for keys, I feel i am missing something due to inexperience here ๐Ÿค”

If you're populating a spreadsheet manually, I'd just drag the previous key's cell down to generate an ascending series. It's really entirely up to you. Just ensure the Key column has a value, else AppSheet won't see that row.

Single sheets with slices, I havenโ€™t thought of that and thatโ€™s definitely better ๐Ÿ™‚

Thanks a million @Steve ๐ŸŒท

Top Labels in this Space