USE THE IF FUNCTION WITH CALCULATE.

1,533 views
Skip to first unread message

Kenyan Aloo

unread,
Apr 14, 2013, 4:49:08 AM4/14/13
to kobo-...@googlegroups.com
Hello Kobo Users,

I am currently working on developing a form for sampling that uses a household listing and KISH Grid system. I would like to use the IF function together with calculate. Is there a way around it. Let me give an example of what am trying to do. I would like to use CALCLUATE to check IF a previous Question had a given value IF SO it concats from a different question, ELSE it checks another value to make it concat from a different Question. Has somebody ever tried using the IF function? Will really appreciate some help on this. Further still anyone developed a form based on KISH grid?

Thank you.
Aloo






Kenyan Aloo

unread,
Apr 14, 2013, 11:35:59 AM4/14/13
to kobo-...@googlegroups.com
One of those moments that you sort your own problem. I managed to make it work by combining it with a concat function and adding several IF operation. It runs on the system quite well. However if anyone has shorter way of doing it I will really appreciate. This is the way I wrote the calculate to enable me check 20 different questions and return String from one of 20 other questions to my question:

calculate="if(/HHList_14A13/Kish1= 1,concat(/HHList_14A13/Member1,''),if(/HHList_14A13/Kish1= 2,concat(/HHList_14A13/Member2,''),if(/HHList_14A13/Kish1= 3,concat(/HHList_14A13/Member3,''),if(/HHList_14A13/Kish1= 4,concat(/HHList_14A13/Member4,''),if(/HHList_14A13/Kish1= 5,concat(/HHList_14A13/Member5,''),if(/HHList_14A13/Kish1= 6,concat(/HHList_14A13/Member6,''),if(/HHList_14A13/Kish1= 7,concat(/HHList_14A13/Member7,''),if(/HHList_14A13/Kish1= 8,concat(/HHList_14A13/Member8,''),if(/HHList_14A13/Kish1= 9,concat(/HHList_14A13/Member9,''),if(/HHList_14A13/Kish1= 10,concat(/HHList_14A13/Member10,''),if(/HHList_14A13/Kish1= 11,concat(/HHList_14A13/Member11,''),if(/HHList_14A13/Kish1= 12,concat(/HHList_14A13/Member12,''),if(/HHList_14A13/Kish1= 13,concat(/HHList_14A13/Member13,''),if(/HHList_14A13/Kish1= 14,concat(/HHList_14A13/Member14,''),if(/HHList_14A13/Kish1= 15,concat(/HHList_14A13/Member15,''),if(/HHList_14A13/Kish1= 16,concat(/HHList_14A13/Member16,''),if(/HHList_14A13/Kish1= 17,concat(/HHList_14A13/Member17,''),if(/HHList_14A13/Kish1= 18,concat(/HHList_14A13/Member18,''),if(/HHList_14A13/Kish1= 19,concat(/HHList_14A13/Member19,''),if(/HHList_14A13/Kish1= 20,concat(/HHList_14A13/Member20,''), ''))))))))))))))))))))"

Kenyan Aloo

unread,
Apr 14, 2013, 2:05:56 PM4/14/13
to kobo-...@googlegroups.com

Hello Kobo Users
I also noted one thing when using questions that have more than one dependent like the one below. You cannot place several of those questions in a group using the new widgets settings of appearance="field-list">. What KOBO Collect does is that it only computes the First One only.

Just for the record I finalized the KISH Grid form and its working pretty well.

Thanks.
Aloo


On Sunday, April 14, 2013 11:49:08 AM UTC+3, Kenyan Aloo wrote:

Neil Hendrick

unread,
Apr 15, 2013, 1:48:13 PM4/15/13
to kobo-...@googlegroups.com
Fantastic use of the Calculate function!
I assume you are using this to select a respondent from a household of several persons. 
In the field we often use a simple expedient, which is to select the person whose first name's first letter is closest to the beginning of the alphabet. This method assumes (a widely accepted assumption) that there is nothing special about names and that Alex's opinions are just as likely as Zed's opinions. 
I'm glad to see that this super complex Calculate function works, but I wonder if there is a simpler method available to us. What are the question's you are asking to get these values? i.e. What are questions Member1, Member2, Member3, etc?

~Neil

--
You received this message because you are subscribed to the Google Groups "Kobo Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kobo-users+...@googlegroups.com.
To post to this group, send email to kobo-...@googlegroups.com.
Visit this group at http://groups.google.com/group/kobo-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Kenyan Aloo

unread,
Apr 15, 2013, 2:21:06 PM4/15/13
to kobo-...@googlegroups.com

Thanks for the suggestion.  The problem is that the sample selection criteria am using was used in the past 7 rounds of data collection the first round was in 2000. So have to repeat it.

Basically Member 1 e.t.c are also calculate questions. Initially the interviewer collects several pieces of data on each individual house member e.g. Name Age Gender

since these are collected on several phone pages I developed a summary page that lists all household members in a group using the new widgets for appearance:fieldlist. this group contains the questions member 1 2 3 etc.

To answer your question Member 1 is a calculate question that takes the form calculate="concat (name1,'', age1,'', gender1)".

By listing this summary in a group it provides my enumerators a chance to observe the characteristics of all household members in a list.

They then select the members that meet their criteria by filling the corresponding member number into the KISH field list.

The if function therefore generates a similar list of the eligible members based on the KISH list.

The interviewer can then ranmdomize among the listed using a KISH grid system. I tried the calculate="random()" it works however it cant give me a absolute particular random number between 1 and the total number eligible in a household. I managed to seed the random so that it fixes the number it generates but only gives values between 0 and 1 but excludes 1.

THE BOTTOM LINE IS I WOULD RATHER WORK EXTRA HARD TO DEVELOP A COMPLEX XML FORM AS LONG AS THE FIELD TEAM HAVE A VERY EASY AND AUTOMATED SYSTEM THAT IS AN EXACT REPLICA OF WHAT THEY WOULD HAVE DONE ON PAPER.

I need help on the random such that it generates a number between 1 and reference to a node that contains total number of eligible respondents. I get the total eligible through calculate countnotempty which works. 

Peter Kinuthia

unread,
May 21, 2013, 5:01:24 AM5/21/13
to kobo-...@googlegroups.com
Hi Aloo,
Kindly take me through how to export value labels in kobocollect  on a filled form.
Your timely feedback will be highly appreciated.
Kind Regards
Peter


On Sunday, April 14, 2013 11:49:08 AM UTC+3, Kenyan Aloo wrote:

Aloo Stephen

unread,
May 21, 2013, 6:13:06 AM5/21/13
to kobo-...@googlegroups.com
Hello Peter,
Open your form in the Kobo Collect Design Page http://www.kobotoolbox.org/koboform/ then go to menu, SPSS, create SPSS file. You will then need to create an SPSS data from the already existing dummy files of your CSVs then export the same variable labels. One way that has worked for me is to develop an external Excel file that has the codes inbuilt but reads its data from my CSV so as the CSV changes so does the external file. This is especially helpful if you want to give control to


--
You received this message because you are subscribed to the Google Groups "Kobo Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kobo-users+...@googlegroups.com.
To post to this group, send email to kobo-...@googlegroups.com.
Visit this group at http://groups.google.com/group/kobo-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Aloo Stephen Onuong'a
Public Health & Social Research Specialist

Aloo Stephen

unread,
May 21, 2013, 6:15:37 AM5/21/13
to kobo-...@googlegroups.com
Hello Peter,
Open your XML form in the Kobo Collect Design Page http://www.kobotoolbox.org/koboform/ then go to menu, SPSS, create SPSS file. You will then need to create an SPSS data from the already existing dummy files of your CSVs then export the same variable labels. One way that has worked for me is to develop an external Excel file that has the codes inbuilt but reads its data from my CSV so that if the CSV changes so does the external file. This is especially helpful if you want to give control to an independent team (e.g. quality control team) without them editing your CSVs.

Regards
S.Aloo


On Tue, May 21, 2013 at 12:01 PM, Peter Kinuthia <peterki...@gmail.com> wrote:

--
You received this message because you are subscribed to the Google Groups "Kobo Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kobo-users+...@googlegroups.com.
To post to this group, send email to kobo-...@googlegroups.com.
Visit this group at http://groups.google.com/group/kobo-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Neil Hendrick

unread,
May 21, 2013, 1:34:02 PM5/21/13
to kobo-...@googlegroups.com

There is a video tutorial on how this is done here:
Reply all
Reply to author
Forward
0 new messages