Question with Dependent Dropdowns

NCD
Silver 2
Silver 2

I have a Product table and a Line Item table. The dependent dropdown works but if I only have one product with that category I want it to auto select the product for me. Is this possible?

image.png

Solved Solved
0 5 129
1 ACCEPTED SOLUTION

If I understand your requirement correctly, here is what you can try.

In the initial value of id_product column in Line Item, put an expression like,

IF(
 COUNT(
  FILTER(
   "Product",
   [Category] = [_THISROW].[Category]
  )
 ) = 1,
 LOOKUP(
  [_THISROW].[Category],
  "Product",
  "Category",
  "Id"
 ),
 ""
)

Also set rest on edit. 

View solution in original post

5 REPLIES 5

Aurelien
Google Developer Expert
Google Developer Expert

Hi @NCD 

yes, here:

Define App formulas and Initial values - AppSheet Help

You may want to use a ANY(yourlist) expression.

don't quite get it :S

So my Category column in my Line Item table is set to Enum and I have a valid if expression;

Product[Category]

And Enum type Ref for my id_Product and a valid if expression;

Product[id]

you're saying I should have ANY() where? and by (yourlist) meaning id_Product?

Aurelien
Google Developer Expert
Google Developer Expert

In the initial value field:

Aurelien_0-1666863205928.png

Maybe this:

ANY(Product[Category])

 

If I understand your requirement correctly, here is what you can try.

In the initial value of id_product column in Line Item, put an expression like,

IF(
 COUNT(
  FILTER(
   "Product",
   [Category] = [_THISROW].[Category]
  )
 ) = 1,
 LOOKUP(
  [_THISROW].[Category],
  "Product",
  "Category",
  "Id"
 ),
 ""
)

Also set rest on edit. 

Thank you!

Top Labels in this Space