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".
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
The outermost tag that defines that you have a crosstab
- Name - The crosstab name (default: "New Crosstab")
- Description - The description of the crosstab (default: none)
Creates a group heading and can contain multiple segments <sec>
- 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)
Define a specific banner point within your custom crosstab
- Name - The segment name (default: "New Segment")
Outlines the specific logic (ie, condition) that defines your specific banner point
- <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.
- <And /> Joins two <cond> tags with AND, which filters respondent data where both conditions must be true.
- </ /> 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 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
<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:
(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
Excludes empty data fields from the logic (when applicable). Otherwise empty data fields will be evaluated to "0" and included in the logic.
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
- If the end time is a day, it's assumed to be end of that day (specify 14-Mar-2013 the 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 above 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> </ sec> </ XTAB>
Inside each report, you must use the <seg> </ sec> and <cond> </ cond> tags to define your banners. There is one <sec> </ sec> 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> </ sec>, linked with the condition joiners.
<Seg name = "Male 18-34"> <cond> (q1.r1) </ cond> <and /> <cond> (q2.r1 or q2.r2) </ cond> </ sec> <seg name = "Male 44 or under"> <cond> (q1.r1) </ cond> <and-not /> <cond> (q2.r5) </ cond> </
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 uses alternate (alt) labels, you must reference the original question label.
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.
- R1 - Male
- R2 - Female
- R1 - Under 18
- r2 - 18-24
- R3 - 25-34
- r4 - 35-44
- R5 - 45 or older
- 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> </ sec>
Example # 2
<sec name = "Male and not (45 or older)"> <cond> (q1.r1) </ cond> <and-not /> <cond> (q2.r5) </ cond> </ sec>
Example # 3
< / Li> </ li> </ li> </ li> </ li> </ li> < li> </ li> >
Example # 4
< / Li> </ li> </ li> </ li> </ li> </ li> < li> </ li> >
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 do not 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>
- Use CTRL + ENTER to update the XML and close the editor.