A computed column is one of the most useful analytical tools in 1010data. Use a
computed column to add a column of information to a worksheet typically using the
information from one or more existing columns.
Computed columns are columns you create yourself in many cases using
information that is already in the table with which you are working. For example,
suppose you have a table that contains all the sales data for a chain of stores.
This table has one column called Sales, which is the purchase
price paid by the customer. It has another column called
Cost, which is the cost of the item to the retailer. With a
computed column, it is easy to create a third column called
Margin that contains the difference between the sale
price and the cost. In this tutorial, you will use the Sales Item
Detail table to find the margin using a computed column.
To
create a computed column:
Open the Sales Item Detail table
(pub.demo.retail.item) by completing the
following:
In the Folders and Tables browser, enter
pub.demo.retail.item in the toolbar search
field.
Click the Go ()
icon.
1010data displays the Sales Item Detail
table.
In this tutorial, the
Sales and Cost columns,
outlined above, are used to create the Margin
computed column.
Click Columns > Create Computed Column.
1010data displays the Create Computed Column
dialog.
Complete the following fields in the Create Computed
Column dialog:
Column Name
Enter margin.
This is the name
1010data uses to interact with the column. It is also used when
writing more advanced value expressions and queries. The column
name may only contain alphanumeric characters or underscores and
must begin with an alphabetic character (e.g.,
percent_total_sales). It may not contain any spaces or other
special characters.
This is a required
field.
Column Heading
Enter Margin.
This is the label of the
column that displays by default at the top of a column in the
user interface. The column heading may contain any combination
of uppercase and lowercase letters, numbers, spaces, and special
characters. If you want to have a multi-line column heading, use
the backtick character (`) to separate the lines (e.g.,
"Percentage of`Total Sales (%)").
While not required, this
field is recommended.
Value Expression
Enter sales-cost.
In 1010data, a value
expression is a calculation you create to help you analyze your
data. In this case, the value in the cost
column is subtracted from the value in the
sales column.
You can write a value
expression that performs either simple or advanced
calculations.
This is a required field.
Display Format
Select Number: 1,234,567.89.
This
drop-down list instructs 1010data how to display the new number
in the computed column. For example, as a date, a number, as
text, and so forth.
This field is not required and can
usually be left as the default value.
Column Width
Select 5.
This drop-down list
determines how many place values to hold in the column. In other
words, the width of the column by the number of
characters.
This field is not required and can usually be
left as the default value.
Decimal Places
Select 2.
This drop-down list sets how
many numbers are displayed after the decimal point.
In
this tutorial, dollar amounts are used. Therefore, two decimal
places are usually the appropriate setting. However, as you
explore 1010data and computed columns, you may find that there
are situations where you need more or none at all.
This
field is not required and can usually be left as the default
value.
You might be asking yourself, "What is actually happening here?" To put it
simply, what you just entered above indicates you are creating a new
computed column named margin. The margin
column is the value of the sales column minus the value of
the cost column.
You might have noticed the small table at the bottom of the Create
Computed Column dialog. This table is helpful in finding the
name for the columns in this table. It is important to remember when writing
a value expressions to always use the column name, not the column
heading.
Click Submit.
1010data creates the Margin computed
column.
When you are finished with this tutorial, close the Sales Item
Detail worksheet.
You just created a new column in the worksheet with a very small amount of effort.
The values in each row are calculated by the equation you entered as the value
expression, and you can now easily see the margin for every item sold in the entire
worksheet. Of course, computed columns are much more powerful than merely
subtracting or adding one column from another. With a little practice, you will be
able to build columns based on more complicated equations, such as standard
deviations and Sharpe ratios.
To learn more about computed columns and value expressions, see Computed Columns in the 1010data User's
Guide.