Hello again,

In my survey, I repeatedly sample the same taxa. Hence, in order not to enter all information over and over again, I would like Open Foris to recognise whether a taxon had already been sampled within the sampling unit.

So far, I unsuccessfully tried with the following code which is to be added into the "only when expression is verified" field: true(idm:contains(parent()/a_in_ind/taxon,taxon))

Am I getting it wrong?

Thanks for the help in advance, Jan

asked 16 Mar, 10:42

janklein's gravatar image

janklein
111
accept rate: 0%


Dear Jan,
First of all, when you are working with complex expressions using a composite attribute, like taxon, that has multiple fields, it would be better to extract the code value into a calculated attribute, that you could call species_code, with an expression like this:

species/@code

Then you could verify, into another calculated attribute, hidden in data entry, that the same species has been already sampled in another calculated attribute (e.g. species_already_sampled) with an expression like this:

count(parent()/individuals[species_code = $context/species_code]) > 1

that means that there is at least one row in your table having the same species code of the current row. The expression $context/species_code is a shortcut for $this/parent()/species_code.
After that, you can use the species_already_sampled value into a Relevant when condition, to make a field relevant and trigger the apply of the default value expression on it.

Let us know if this will help you to solve your problem.
Many thanks,
Open Foris Team

permanent link

answered 16 Mar, 22:24

OF%20Collect's gravatar image

OF Collect ♦♦
3.8k18
accept rate: 22%

Dear Stefano,

thank you very much for your quick reply. The workaround works fine.

Just one last question: How can I use species_already_sampled as a condition? It seems like it outputs a boolean (true/false). When trying to code "true(species_already_sampled)", OF runs into an error. I also tried "species_already_sampled = 'true'", but the code doesn't work.

Thanks again,

Jan

permanent link

answered 17 Mar, 09:49

janklein's gravatar image

janklein
111
accept rate: 0%

Dear Jan,
You can use write just species_already_sampled in the Relevant when expression, to make an attribute relevant in that case and apply a default value on it, for example. You don't need to cast the result of the expression into a boolean value, since it's already boolean.
Many thanks,
Open Foris Team

permanent link

answered 17 Mar, 14:36

OF%20Collect's gravatar image

OF Collect ♦♦
3.8k18
accept rate: 22%

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:

×438

question asked: 16 Mar, 10:42

question was seen: 200 times

last updated: 17 Mar, 14:36