Axis expressions
When creating Long, Double, Text, Date, Boolean, and Categorical questions, you can use the optional axis keyword to define the axis expression to be used in UNICOM Intelligence Reporter. For example, you can define the banding and special elements to be used by default when tabulating numeric variables and add special net elements to categorical variables.
Syntax
Specify the axis expression at the end of a Long, Double, Text, Date, Boolean, or Categorical question as follows:
axis ( "<axis_specification>" )
Parameter
<axis_specification>
Must be valid axis specification syntax. Do not include the variable name, just the element list syntax. Be careful to check your syntax and spelling carefully, because the axis expression is stored without being validated. For full details of the element list syntax, see
Element list syntax.
Notes
If an axis does not contain a base element, the Table Object Model (TOM) always inserts one at the start of the axis. It is therefore not generally necessary to define a base element in your axis specifications.
When you include a custom label in an axis expression, you can enclose the label text in single quotation marks or two double quotation marks. For example:
'My label'
or
""My label""
If you use single quotation marks, you must escape any single or double quotation marks included in the label with a second quotation mark of the same type. This indicates that the quotation mark used in the label does not represent the end of the label. If you use two double quotation marks, you must escape any double quotation marks used in the label with three double quotation marks.
Sometimes, axis expressions use the expression axis specification keyword to create a special element based on a custom expression. When you do this, you can enclose the expression text in single quotation marks or two double quotation marks. However, if the expression itself contains a text literal, you must escape the double quotation marks used to enclose the text literal as you do when a label contains a double quotation mark. For example:
... expression('gender = {Male}') ...
... expression(""gender = {Male}"") ...
... expression('Entrance = ""Main"" And Gender = {Female}') ...
Examples
In the following examples the axis expressions are shown on multiple lines to aid readability. However, in practice you must not include line breaks in the axis expression.
1. Numeric variables
The following creates an integer variable that stores each respondent's age as a numeric value and includes an axis expression that bands the age values into two categories and includes a special mean element.
Ages "Age of respondents" long
axis ("{younger 'Younger people' expression('ages < 35'),
older 'Older people' expression('ages > 34'),
mean 'Mean age' mean(ages)}");
The following creates a real variable that stores each respondent's annual income and includes an axis expression containing special statistical elements.
Income "Annual income" double
axis ("{min(income), max(income), mean(income), stddev(income)}");
2. Text variable
The following creates a text variable that stores each respondent's address and includes an axis expression that automatically codes the response into categories by using the
Find function to search for city names.
Address text [1..150]
axis ("{London 'London' expression('address.find(""london"") <> -1'),
Liverpool 'Liverpool' expression('address.find(""liverpool"") <> -1'),
Aberdeen 'Aberdeen' expression('address.find(""aberdeen"") <> -1'),
Leeds 'Leeds' expression('address.find(""leeds"") <> -1'),
Edinburgh 'Edinburgh' expression('address.find(""edinburgh"") <> -1'),
OtherCities 'Other cities' expression('address.find(""london"") = -1
And address.find(""liverpool"") = -1
And address.find(""aberdeen"") = -1
And address.find(""Leeds"") = -1
And address.find(""Edinburgh"") = -1
And Not address.IsEmpty()'),
NotAnswered 'Not answered' expression('address.IsEmpty()')}");
3. Date variable
The following creates a date variable and includes an axis expression that automatically bands the dates into categories based on the month number returned by the
Month function.
TargetDate "Target date" date
axis("{January 'January' expression('TargetDate.Month() = 1'),
February 'February' expression('TargetDate.Month() = 2'),
March 'March' expression('TargetDate.Month() = 3'),
April 'April' expression('TargetDate.Month() = 4'),
May 'May' expression('TargetDate.Month() = 5'),
June 'June' expression('TargetDate.Month() = 6'),
July 'July' expression('TargetDate.Month() = 7'),
August 'August' expression('TargetDate.Month() = 8'),
September 'September' expression('TargetDate.Month() = 9'),
October 'October' expression('TargetDate.Month() = 10'),
November 'November' expression('TargetDate.Month() = 11'),
December 'December' expression('TargetDate.Month() = 12')}");
4. Boolean variable
The following creates a boolean variable and includes an axis expression that automatically creates elements for the True and False responses:
HasChild "Do you have any children under 16 living at home?" boolean
axis("{Yes 'Yes' expression('HasChild = True'),
No 'No' expression('HasChild = False')}");
5. Categorical variable
The following creates a single response rating question that includes an axis expression that combines the top and bottom two rating categories into single elements with the text “Top 2 answers” and “Bottom 2 answers”, respectively:
ProductRating "How would you rate this product?"
categorical [1..1]
{Excellent,
Good,
Neither "Neither good nor bad",
Poor,
XPoor "Very poor"}
axis ("{Top2 'Top 2 answers' combine({Excellent, Good}),
Neither, Bottom2 'Bottom 2 answers' combine({Poor,
XPoor})}");
5. Editing grid and loop iterations
The following demonstrates editing grid and loop iterations:
order{first, second} * order[..].column
See