Hello again,

In my survey, I sample multiple individuals belonging to the same taxon. Each taxon is collected once in the field. Now, I wish to automatically associate each subsequent observation with the corresponding reference specimen.

Technically speaking, I want to pull a value (specimen_name) based on another value (taxon_name). I reckon that using idm:lookup() is the right approach here but I fail to correctly implement the code. Lookup() requires a list of values. Is it that I need to create that list beforehand?

My relevant fields: - taxon_name - specimen_name - taxon_already_sampled (yes/no) - reference_specimen

Desired output: Taxon1 is observed for the first time in the field (taxon_already_sampled = no) and is collected, hence a specimen name is attributed ("specimen1"). Subsequently, taxon1 is again encountered in the field (taxon_already_sampled = yes); in this case the individual will not be collected but instead the column reference_specimen should be auto-filled with "specimen1".

Thanks in advance for the help.

Best, Jan

asked 07 Apr '22, 14:57

janklein's gravatar image

janklein
216
accept rate: 0%


Dear Jan,
The lookup function (idm:lookup) is something you should use to fetch data from a table of the database, is not what you need in your case.
What you should do to get the value of an attribute in another row of the same table is an expression like this:

parent()/tree[taxon_name = $context/taxon_name and idm:position() != idm:position($context)] / specimen_name

With this expression you will get the value of specimen_name of another having the same taxon_name as the current row (but different position in the table, of course).

Let us know, many thanks.
Open Foris Team

permanent link

answered 06 May '22, 10:32

Stefano%20%28OF%29's gravatar image

Stefano (OF) ♦♦
4.8k119
accept rate: 19%

The function does exactly what I wanted to do. Thank you very much!

(24 Oct '22, 14:30) janklein janklein's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×494

question asked: 07 Apr '22, 14:57

question was seen: 919 times

last updated: 24 Oct '22, 14:30