Odk Field Calculation

Dear Already I have been developed odk form. Now I need more calculation issue but I don't know how I do it.

After collect information following is the table structure

Species-Name Plot Seedling (ha)
X 1 200
Y 1 300
Z 2 100
Y 2 200
Z 3 100
m 3 300
n 3 400

I need following information as per these table

Number-of-plot Species-name Avg. Seedlings
X
Y
Z
m
n

Is it possible or not.

Where do you want to do the calculation? Is it part of the Form, where you want to show calculation based on earlier inputs? If yes, then you need to define this in the Docs

If you want to do this calculation after the form is submitted, then you need to write a separate script and make calculation by doing SQL queries.

Would be good if you could attach your form and maybe present a sample flow (step by step). As I understand you need to collect data in a repeat group with 3 questions:

  • Species-Name
  • Plot
  • Seedling

am I right? Then you want to perform some calculations to display data about collected values?

Its a huge form almost 220 questioner. These species information is one section of these form. I need the calculation from these section only.

I need this calculation in the ODK form.

Would be great if you could extract that section and create a sample form that we could use to solve your problem. You didn't attach any form and didn't explain what you need to calculate wel,l so it's hard to help you.

You can call the names of the form elements. As an example, we have a form which has a conditional section. So we have the following

relevant="(
/data/t12x12a/t12x12s1 = '0'
or
((/data/t12x12b/t12x12n1 + /data/t12x12b/t12x12n2) < '10'
or
/data/t12x12c/t12x12n3 < '10')
and
((/data/t12x12b/t12x12n1 + /data/t12x12b/t12x12n2 < '6')
or
/data/t12x12c/t12x12n3 < '6')"

This is one of the more complex logical we have in one of our forms. Since our form is divided in groups, we are using the full variable hierarchy name.

You would probably have something simpler for basic addition, as per the example given in the Calculations section of Docs:

Dear Grzesiek,

Thanks for your reply. Here is the attached odk form and also result format.

SUFAL_Intervention_plan_4.0_demo_test.xlsx (212.0 KB) result.docx (14.5 KB)

So if I pass data like:
Plot/Species-Name/Seedling

1 a 100
1 b 200

2 a 210

3 a 300
3 b 400
3 c 500

How that summary should look like?

1 a,b 150
2 a 210
3 a,b,c 400

or what?

Summary will be

3 a 203.33
2 b 300
1 c 500

Number of plot Species name Avg Seedling

Ok I think now I see so you want to group results by Species-Name then display the number of appearances and it's average seedling, right?

Yes you are right. I need these kind of result view.

It's a complex case and ODK Collect is rather for collecting data then such calculations should be done on server side (or just in excel). Maybe @Xiphware has some ideas.

I agree with you @Grzesiek2010,
Sometimes we turn to forget the purpose of ODK which is to collect data rather than doing some complex data wrangling which can be done at the other end (server).

2 Likes

Thank you for your suggestion.