Skip to main content

FV Decipher Support

All the topics, resources needed for FV Decipher.

FocusVision Knowledge Base

Keyword Coding Questions

1:  About Creating Keyword Coded Questions

You can use keyword coding to group open-end question responses and display the results in a virtual question. Grouping questions by keywords allows you to identify trends in your data.

In this tutorial we take responses from opened-ended questions which have been saved in a coding file and we will use that coding file to fill our virtual questions.

To create these questions in your survey, follow these steps:

  • Set up the coding file
  • Copy the keyword coding questions template into the survey
  • Modify the template according to your design requirements

2: Create Keyword Coding Categories

To get started, you should look at your open-end response data and then determine keyword categories based on trends you see in the data.

In our example, we have come up with 85 different keyword categories to which our open-end responses can be classified.  Each keyword code category will be assigned a value (ex. code101=101, code 203=203, etc.)

Click here to see our example file.

3: Set Up the Coding File

Next, we’ll assign those keyword code categories to each respondent by setting up our coding file.

Your coding file should contain a unique identifier for all respondents in your survey.  In this example, we’re using the uuid variable from the survey, as seen below in the “Respondent” column for our coding file. 

Our coding file also includes a series of code columns, which represent the total number of keyword code categories that a respondent may qualify for (ex. code1, code2, code12)

Note: You may want to include a "Verbatim" column to display all open-end responses per respondent.  However, the "Verbatim" column is completely optional and has no bearing on programming the keyword coding of a virtual question as covered in this tutorial.

Finally, you will need to assign the values from your Keyword Coding Categories to each respondent in your file as appropriate. 

As shown in the figure below, Respondent 6ghasjw02f2c1mxj qualifies for Keyword Categories 306 and 319.

Once you have finished creating the coding file or have received the file from your coders, save it as a tab delimited text file with the .dat extension and upload it to your project’s system files.  Here are the steps:

1. Open the file using Excel 2013.
2. Save file as “Text(Tab Delimited)”.
3. Open the file in Notepad.
4. Select “Save As”, change “Save as Type” to “All Files” and add “.dat” to the file name.
5. Upload the .dat file into your project in the location “System File (root)”

4:  Copy the Keyword Coding Template into the Survey

Please use the following code block as a keyword coding template and copy it into  the survey right after your open ended text that has been previously fielded.

This code sets up the logic and question style necessary to achieve the keyword coding.

With the following template placed in your survey, the next step is to update the template so that it matches your keyword coding.  Instructions are in the following sections.

<exec when="virtualInit">
Q1_coded = File("Q1_coded.dat","Respondent")
</exec>


<text
  label="vQ1_coded_data"
  optional="0">
  <title>vQ1 Coded Data</title>
  <virtual>
respData = Q1_coded.get(uuid)

if respData:
    for eachRow in vQ1_coded_data.rows:
      eachRow.val = respData["code" + eachRow.label.strip("r") ].strip("\r\n")
  </virtual>

  <row label="r1">code1</row>
  <row label="r2">code2</row>
  <row label="r3">code3</row>
  <row label="r4">code4</row>
  <row label="r5">code5</row>
  <row label="r6">code6</row>
  <row label="r7">code7</row>
  <row label="r8">code8</row>
  <row label="r9">code9</row>
  <row label="r10">code10</row>
  <row label="r11">code11</row>
  <row label="r12">code12</row>
</text>

<suspend/>

<checkbox
  label="vQ1_Coded"
  atleast="1">
  <title>vQ1 Coded Data</title>
  <virtual>
for eachRow in vQ1_coded_data.rows:
    if eachRow.val:
        data.attr("r" + eachRow.val).val = 1
  </virtual>

  <row label="r100">bucket 1</row>
  <row label="r101">bucket 2</row>
  <row label="r102">bucket 3</row>
  <row label="r103">bucket 4</row>
  <row label="r104">bucket 5</row>
  <row label="r105">bucket 6</row>
  <row label="r106">bucket 7</row>
  <row label="r107">bucket 8</row>
  <row label="r108">bucket 9</row>
  <row label="r109">bucket 10</row>
  <row label="r110">bucket 11</row>
</checkbox>

5:  Update the Template

Let's walk through each section of the code in the template above to get a better understanding of what's going on and to identify where it needs updating so that it matches your keyword coding.

First, though you should change all prefixes which reference Q1 to prefixes of your actual question label. From within the template, do a global find and replace to replace all instances of Q1 to match your question label.

5.1:  Update the Coding File Name

In the following section of the template, the coding file is initialized. The exec block takes in the name of the design file we uploaded to the project's directory.

Update Q1_coded.dat to reflect the name of the design file you uploaded to your project directory.

Additionally you may need to update "Respondent" to reflect the name of the column you are using to identify unique respondents in your coding file.

<exec when="virtualInit">
Q1_coded = File("Q1_coded.dat","Respondent")
</exec>

5.2:  Update the First Keyword Coding Virtual Question

In the next block of the template below, the virtual question loads the coded data by matching the respondent’s uuid value from the survey with the “Respondent” column value in the coding file. The uuid is a unique identifier created by our system to identify respondents. The virtual question  then populates each row with data from the code columns contained in the coding file. ,/p. In our template we are assuming that the unique identified we are using in “Q1_coded.dat” is the respondent’s “uuid”.

If you are using a different unique identifier, you need to alter the line: “respData = Q1_coded.get(uuid)” to reference the appropriate value (ex. source, myID, etc.).

Also, update the number of rows, row labels, and row text and to match your columns in your coding file. The number of rows should match the number of columns from your file. 

<text
  label="vQ1_coded_data"
  optional="0">
  <title>vQ1 Coded Data</title>
  <virtual>
respData = Q1_coded.get(uuid)

if respData:
    for eachRow in vQ1_coded_data.rows:
      eachRow.val = respData["code" + eachRow.label.strip("r") ].strip("\r\n")
  </virtual>

  <row label="r1">code1</row>
  <row label="r2">code2</row>
  <row label="r3">code3</row>
  <row label="r4">code4</row>
  <row label="r5">code5</row>
  <row label="r6">code6</row>
  <row label="r7">code7</row>
  <row label="r8">code8</row>
  <row label="r9">code9</row>
  <row label="r10">code10</row>
  <row label="r11">code11</row>
  <row label="r12">code12</row>
</text>

5.3:  Update the Second Keyword Coding Virtual Question

The next section of template creates a new virtual question which populates coded answers based on the data from previous virtual question, vQ1_coded_data.

vQ1_Bucketed will go through each row of vQ1_coded_data, and if the row data matches a row label in the vQ1_Bucketed, then the row populates with a value of 1 (True).  For example, if vQ1_coded_data.r1 has the value “103”, then the vQ1_Bucketed.r103 is selected.

According to our code example, anyone who fell into code103 is classified with the keyword “Helpful”. 

For this step, you’ll need to update the:

1. Rows so that it matches the total number of keyword code categories.
2. Row labels so that it matches the values from your keyword code categories (ex. code101=r101).
3. Row text so that it matches the corresponding keyword code categories (ex. replace “bucket 2” with “Friendly”).

<checkbox
  label="vQ1_Bucketed"
  atleast="1">
  <title>vQ1 Bucket Coded Data</title>
  <virtual>
for eachRow in vQ1_coded_data.rows:
    if eachRow.val:
        data.attr("r" + eachRow.val).val = 1
  </virtual>

  <row label="r100">bucket 1</row>
  <row label="r101">bucket 2</row>
  <row label="r102">bucket 3</row>
  <row label="r103">bucket 4</row>
  <row label="r104">bucket 5</row>
  <row label="r105">bucket 6</row>
  <row label="r106">bucket 7</row>
  <row label="r107">bucket 8</row>
  <row label="r108">bucket 9</row>
  <row label="r109">bucket 10</row>
  <row label="r110">bucket 11</row>
</checkbox>

6:  Test Your Survey

That’s it! You’ve finished creating a virtual question to group responses from an open-end question into keyword categories. 

Test your survey by verifying that the virtual questions match the pivot table in Excel.

Note: You will need to repeat this process for each keyword code sheet.