Skip to main content

FV Decipher Support

All the topics, resources needed for FV Decipher.

 
FocusVision Knowledge Base

Using XML to Edit Crosstabs

 

1:  Accessing the XML in Crosstabs

First, open Crosstabs for your project.

To access the XML for a saved crosstab, locate the crosstab and click "Edit Crosstab".

2015-04-08_0828.png

Then click "XML".

To access the XML for a new crosstab, select "Build Crosstab".

Then click "XML".

Edit the crosstab using XML. If you are familiar with coding, this can be an easy way to edit or modify the report and find errors not always visible from the graphical user interface (GUI). Select "Update" once you have completed your edits. Click "Cancel" or X to revert your code back to its previous content (any changes you made will be lost).

2:  Logic Syntax

Note that the labels in the XML are case sensitive.
All tags that are open must also be closed, using the forward slash ( / ).

2.1:  XML Tags & Their Attributes

1.  <xtab>
The outer most tag that defines that you have a crosstab

<xtab> Attributes:

  • name - The crosstab name (default: "New Crosstab")
  • description - The description of the crosstab (default: none)

2.  <group>
Creates a group heading and can contain multiple segments <seg>

<group> Attributes:

  • name - The group name (default: "New Group")
  • showHeader - Show or hide the group as a heading in the report table  (set to true or false; default: true)

3.  <seg>
Defines a specific banner point within your custom crosstab

<seg> Attributes:

  • name - The segment name (default: "New Segment")

4.  <cond>
Outlines the specific logic (i.e., condition) that defines your specific banner point

<cond> Totals:

  • <cond> (ALL) - The segment logic represents all respondents in the crosstab
  • <cond> (ALL_IN_GROUP) - The segment logic represents the count/percentages of the segments within a group. Otherwise, count/percentages is based on all segments in the crosstab.

<cond> Joiners:

  • <and />  Joins two <cond> tags with AND, which filters respondent data where both conditions must be true.
  • <or />  Joins two <cond> tags with OR, which filters respondent data where either condition can be true.
  • <and-not />  Joins two <cond> tags with AND NOT, which filters respondent data where the first condition must be true and the second condition must be false.
  • <or-not />  Joins two <cond> tags with OR NOT, which filters respondent data where the first condition can be true or the second condition can be false.

2.2:  Logic Syntax for Conditions

2.2.1:  Closed-end Questions

1-dimensional single select, multi-select or dropdown menu question:

<cond>q3.r1</cond>

Checks checks "r1" was selected in q3

2-dimensional single select, multi-select or dropdown menu question:

<cond>q3.r1.c1</cond>

Checks if for r1 in q3, "c1" was selected

<cond>q4.r1.any</cond>

Checks within r1 of q4 if any option was selected

<cond>q4.but(q4.r1).any</cond>

Checks if anything within q4, but excluding q4.r1 was selected

Multi-select question:

<cond>q4.count > 2</cond>

Checks if the number of checkboxes checked was greater than 2

2.2.2:  Open-ended Questions

Text and Essay questions:

<cond>Q2.search("some text")</cond>

Matches Q2's textual value against this string (not case sensitive) within the question (ASCII character set only)

Number and Float questions:

<cond>(Q3.check('1-100')) or (Q3.check('>399')) or ( Q3.check('<50'))</cond>

Checks for items within the range, 400 and above, or less than 50

<cond>Q5.sum > 25</cond>

Checks if the sum of the numeric question is greater than 25

Number questions

1 <cond>(q4.val is not None) </cond>

    Excludes empty data fields from the logic (when applicable). Otherwise empty data fields will be evaluated to "0" and included in the logic.

2.2.3:  Dates

date_range(start, end) checks whether the completion date is within that range, in the server's time zone.

  • The dates can be one of "01-mar-2013", "01-mar-2013 14:32" or "01-mar-2013 14:32:00"
  • The month is case insensitive
  • The time is 24H time
  • If the end time is a day, it's assumed to be end of that day (so specifying 14-mar-2013 as end time means until the 23:59:59 on that day). Leave out end to default to the end of the start day.
  • Use 'now' as a dynamic end date to reference "today". This logic is only accessible in the XML, it is not supported in the logic editor.

Example of respondents completing on 3/25/14:

<cond>date_range("25-Mar-2015", "25-Mar-2015")</cond>
date_days(start, end) checks for a rolling date range.
  • "start" equal to 0 means beginning of today, 14 means beginning of the day 14 days ago
  • The end defaults to now if left out, otherwise it's the end of the day specified as using the start syntax
  • This syntax correctly accounts for daylights saving time

Example of respondents completing in the  last 7 days:

<cond>date_days(7)</cond>

2.2.4:  Nested Logic

Segment logic can use parentheses or a logic joiner to change logic precedence, which creates nested boolean logic.

The example below shows multiple ways that logic for Males (q1.r1) who selected either "Brand A" (q3.r1) or "is 35-44" (q2.r4)  can be entered in the XML.

Using a single condition:

<cond> (q1.r1) and (q2.r4 or q3.r1)</cond>

Using conditions separated with a logic joiner:

<cond>(q1.r1)</cond>
<and />
<cond>(q2.r4 or q3.r1)</cond>

2.3:  Combining Tags & Conditions

The XML file is a series of nested XML tags. There will be only one set of <xtab></xtab> tags that surround all of your segments and groups.

<xtab name="New Crosstab">
  <seg name="Total">
    <cond>(ALL)</cond>
  </seg>
</xtab>

Inside each report, you must use the <seg></seg> and <cond></cond> tags to define your banners. There is one <seg></seg> for each banner point you want to include in your report, and must include a name (name=""). The <cond></cond> tags are then nested to define the logic for each banner point; you can have one or more <cond></cond> tags inside each <seg></seg>, linked with the condition joiners.

<seg name="Male 18-34">
    <cond>(q1.r1)</cond>
    <and />
    <cond>(q2.r1 or q2.r2)</cond>
</seg>
<seg name="Male 44 or under">
    <cond>(q1.r1)</cond>
    <and-not/>
    <cond>(q2.r5)</cond>
</seg>

2.4:  Defining the Variable Names

In the above example using the <cond></cond> tags, the logic was defined using the syntax (q1.r1). These references, "q1" and "r1" are specific variable names used within the survey. To find the appropriate variable references, you can download the survey datamap, available in the download feature of the report. You can use the "direct to browser" option, which loads the datamap in your current browser. The datamap shows each question and the associated label. For more information on how to find the proper report, click here.

Tip: If your project utilizes alternate (alt) labels, you must reference the original question label.

2.5:  Examples

The labels and conditions are used to create the proper logic for specifying each segment.  Using a portion of a datamap, below is the description of custom segments using the <cond></cond> tags.

Example Datamap:

[q1]
Gender:
  • r1 - Male
  • r2 - Female
[q2]
Please select your age range:
  • r1 - Under 18
  • r2 - 18-24
  • r3 - 25-34
  • r4 - 35-44
  • r5 - 45 or older
[q3]
Which is your favorite brand?
  • 0 - Unchecked
  • 1 - Checked
  • r1 - Brand A 
  • r2 - Brand B 
  • r3 - Brand C 
  • r4 - Brand D

Example #1

<seg name="Male">
    <cond>(q1.r1)</cond>
</seg>

Example #2

<seg name="Male and not (45 or older)">
    <cond>(q1.r1)</cond>
    <and-not />
    <cond>(q2.r5)</cond>
</seg>

Example #3

<seg name="Male and (Brand A or B)">
    <cond>(q1.r1)</cond>
    <and />
    <cond>(q3.r1 or q3.r2)</cond>
</seg>

Example #4

<seg name="Male and (Brand A and B)">
    <cond>(q1.r1)</cond>
    <and />
    <cond>(q3.r1 and q3.r2)</cond>
</seg>

3:  Tips & Tricks

One of the best ways to learn the proper syntax is to build out custom reports using the report builder, then go back and review the code it generated.

The XML editor will also optimize the code when you save it. You don't have to separate out the logic for the segment. If you enter:

<cond>(q1.r1 or q2.r1) and q3.r1</cond>

the XML editor will save and update it to the nested logic:

<cond>(q1.r1 or q2.r1)</cond>
<and />
<cond>q3.r1</cond>

Hotkeys:

  • Use CTRL + ENTER to update the XML and close the editor.