Creating list from values in same row (and in different table)

Good morning,

I have a table (Plants established) with the following columns:
-name of farmer (Farmer)
-quantity of trees B (Tree B)
-quantity of trees A (Tree A)
โ€ฆ

I have another table (Follow-up) with the following columns:
-name of farmer (Farmer)
-Species tree A
-Tree A alive (Y/N)
-Species tree B (Y/N)
-Tree B alive (Y/N)
โ€ฆ

Not all the farmers have the same plants on their farm. I would thus like to create a form (based on the table Follow-up) where each โ€œSpecies tree Aโ€ will give me only the species that the farmer established (Tree A >=0) (dependent dropdown).

I thought of creating a Enum variable and to create the following list (as suggested variables):
List(if(Plants established[Tree A]>=1,โ€œTree Aโ€,""), if(Plants established[Tree B]>=1,โ€œTree Bโ€,"")โ€ฆโ€ฆ)

-But this gives me the following error:
Cannot compare List with Number in (Plants established[Tree A] >= 1)
-It also cannot think of a way to link this to each single producerโ€ฆ

Could anyone think of a solution? Happy to clarify any doubt.
Thank you so much in advance.

0 14 148
14 REPLIES 14

The if(s) needs to include a COUNT() function like this:

if(COUNT(Plants established[Tree B]) >=1 ,โ€œTree Bโ€,"")

Hi John!
Thank you for your help.
I tried your suggestion but I receive the same error โ€œCannot compare List with Number in (Plantas established[Tree A] >= 1)โ€
Also, I am not sure whether this would do a selection by producer, would it?

Thank you!

Youโ€™ll notice that I had said โ€œIf(s)โ€ - plural. You need to make the same change to any of the expressions that are using that similar pattern.

To explain further โ€ฆ this part of each expression, Plants established[Tree B], returns a list of all the values from the column [Tree B]. AppSheet does not automatically return the number of items in the list for you. So, by wrapping it with the COUNT function like so COUNT(Plants established[Tree B]), the expression will be given that count of items to compare with the >= 1 part.

Good morning John,

Thank you for your explanation.
Unfortunately I did try the If(s) with a COUNT() in every expression, but I still keep receiving the same error codeโ€ฆ

Also, I do not need the number of items, but the name of the item in case the producer established more than one plant. Would this make more sense?

Steve
Platinum 4
Platinum 4

Your problem description is confusing. Please describe your problem in plain language without using any AppSheet terms, and without describing how you think you might approach it. Just describe the problem.

Iโ€™m really not understanding what are you trying to do since we have no insight of your tables schema.
I mean that we need to know wich columns are ref, and that kind of stuff.
Keep your mind open since your schema could be completely wrong for the kind of thing that you want to do. (Could)
Try to explain whatโ€™s the real life scenario and then we could help you to take that to the app

Thank you for your answers.
In one table, I have the names of all the producers and the quantity of plants established on their farm (columns would thus be: producer name, #plants A, #plants B, #plants Cโ€ฆ).
In another table, I want the technician to give me the species of the plants they find, and whether the plants are alive (columns would thus be: producer name, species plant 1, is plant 1 alive, species plant 2, is plant 2 alive, species plant 3, is plant 3 aliveโ€ฆ).
However, not all the producers have received the same plants. I want the form to give me options of species (as a dropdown menu), but only for the species the producer has actually established. The idea would thus be to link the producer name in both tables, and to only show the plants that were established (for example, if #plants A > 1, then the species A will appear in the dropdown menu if that producer is selected).
Is this clearer? Thank you for the patience.

Is there going to be a fixed ammount of columns (plants) for the lifetime of the app? Because this might not be the best database design.
Try to think of columns as characteristics of a thing and not the thing itself

Yes there will be a fixed amount of columns/plants.
The reason for this particular set-up is that the first table is a form where producers can enter how many plants of each type they established.
Do you think that makes the dropdown impossible to create?

Like this?

Key Producer Plants A Plants B Plants C
bla1 John 12 12 40
bla 2 Steve 32 23 10

So a technician should be able to select a certain Producer and then make an inspection, right? Which column type is [Species Plants X] columns?

The same kind of plants or the same quantity? We defined that the columns where going to be fixed so it should be quantity (>=0)

You need an species table since to this point we have been talking about Plants. Confirm the column type of [Species Plant X] (I guess it will end up being EnumList base type Ref)

Do you mean the species related to the Plants the producer has established?

This is the easier part. Just center on the first one for the moment

Yes your first table is exactly what I meant.

Yes, the technician should be able to select a producer and then make an inspection.
[Species Plants X] should be Enum I believe.

Not all the same producers have received the same plants (some only species A and C, some only species B), nor the same quantity.

OK, I can create a species table.

Yes, I mean the species related to the Plants the producer has established.

Thank you very much for your time.

So all received the same plants but not the same quantity.
Think about this on a way that receiving 0 plants equals to the fact of receive that plant, just 0 quantity.
This makes sense from the database perspective.
To not receive a plant could mean that the field is blank but we want to use numbers (>0) on those columns.
Iโ€™m right?

You have a good point! You are right indeed.

So would you have any suggestions based on the above?

Top Labels in this Space