Custom Calculated Column
How to Create a Calculated Column in Data Export
A calculated column is a custom column that works out a new value using a formula. You write the formula in PostgreSQL, and Data Export runs it for every row in your report. For example, you can subtract cost from sales to show profit, or join two text fields into one.
Before you start
Calculated columns use PostgreSQL, a common database language. You will find this feature easier to use if you know the basics of PostgreSQL. If you are new to it, use the built-in documentation and field suggestions in the editor to help you.
Steps to create a calculated column
Open your report and click Columns.
Click the Add Custom Column icon.
Click Calculated Columns.
Enter a name for your column in the field name box.
Click the empty space below the name to open the formula editor.
Write your formula in PostgreSQL.
Save the column to add it to your report.

Tips for writing your formula
Use Show Documentation to find functions
Click Show Documentation in the editor to see a list of functions you can use in your formula. Each function shows what it does, so you can pick the right one for your calculation.
Use field suggestions to add columns
Start typing a keyword, such as “price” or “quantity,” and the editor will suggest matching fields. Click a suggestion to add it to your formula. This helps you avoid spelling mistakes in field names.
If your calculated column does not work
Check your formula for these common problems:
A field name is spelled wrong. Use the field suggestions to add fields instead of typing them.
A bracket or quote mark is missing.
You are doing math with a text field. Math only works with number fields.
Frequently asked questions
Do I need to know PostgreSQL to use calculated columns? Basic knowledge helps. If you are new to PostgreSQL, the Show Documentation list and the field suggestions can guide you through simple formulas.
Can I filter or sort by a calculated column? Yes. Once you add it to your report, you can use custom filters on calculated columns. To learn more, see How to Filter a Report in Data Export.
What is the difference between a calculated column and a static column? A calculated column works out its value with a formula. A static column holds a fixed value that you enter yourself.
String Functions for Calculated Columns in Data Export
String functions let you change or measure text in a calculated column. You can count the characters in a value, change text to lower case or upper case, or join text and fields together. Use these functions in the formula editor when you create a calculated column.
Data Export groups calculated column functions by format: String, Numbers, Boolean, Date & Time, and other custom fields. This article covers String functions.
Count the characters in a text field
The char_length function counts how many characters are in a value. Spaces count as characters too.
Syntax
Example
Coffee Mug
10
Gift Card
9
This is useful for checking that product titles or SKUs are not too long or too short.
Change text to lower case
The lower function changes every letter in a value to lower case.
Syntax
Example
Coffee Mug
coffee mug
CLASSIC T-SHIRT
classic t-shirt
This is useful when the same value is written in different ways, and you want them all to look the same.
Change text to upper case
The upper function changes every letter in a value to upper case.
Syntax
Example
csbk-red-01
CSBK-RED-01
Tsht-Blk-01
TSHT-BLK-01
This is useful for making codes like SKUs or discount codes easier to read.
Join text and fields together
The || operator joins two or more values into one. You can join fixed text with a field, or join two fields.
Syntax
Put fixed text inside single quote marks. Add || between each part you want to join.
Example
To add the word “Qty: “ before a quantity, join the text with the Net quantity field:
3
Qty: 3
12
Qty: 12
This is useful for adding labels to values, or for combining fields like first name and last name into one column.
If a string function does not work
Check that the field name is spelled correctly and sits inside square brackets. Check that fixed text is inside single quote marks, not double quote marks. If you still see an error, click Show Documentation in the editor to check the syntax.
Frequently asked questions
Do spaces count in char_length? Yes. Every space counts as one character. For example, “Gift Card” has 9 characters.
Can I use these functions together? Yes. You can put one function inside another. For example, you can join two fields and then change the result to upper case.
Number Functions for Calculated Columns in Data Export
Number functions let you do math with the fields in your report. You can add, subtract, multiply, or divide field values, and limit how many decimal places a result shows. Use these functions in the formula editor when you create a calculated column.
This article covers Number functions. For text, see String Functions for Calculated Columns.
Add field values together
Use + to add two or more fields.
Syntax
Example: Add Subtotal and Shipping to get the full amount a customer paid.
40.00
5.00
45.00
120.00
10.00
130.00
Subtract one field value from another
Use - to subtract one field from another. You can subtract more than one field in the same formula.
Syntax
Example: Subtract Cost from Net sales to see your profit.
45.00
20.00
25.00
130.00
70.00
60.00
Multiply field values
Use * to multiply two or more fields.
Syntax
Example: Multiply Price by Net quantity to get the total value of each order line.
15.00
3
45.00
8.50
2
17.00
Divide one field value by another
Use / to divide one field by another.
Syntax
Example: Divide Total sales by Order count to get the average order value.
500.00
10
50.00
900.00
12
75.00
Limit the number of decimal places
Use trunc to cut a number down to a set number of decimal places. Replace n with how many decimal places you want to keep.
Syntax
Example: Keep 2 decimal places in Average order value.
45.6789
trunc([Average order value],2)
45.67
12.3
trunc([Average order value],2)
12.30
Note that trunc cuts off the extra digits. It does not round. For example, 45.6789 becomes 45.67, not 45.68.
If a number function does not work
Check these common problems:
One of the fields is text. Math only works with number fields. A number stored in a String column cannot be used in a calculation.
You are dividing by zero. If the second field is 0 in any row, the division will fail for that row.
The result has no decimals. If both fields are whole numbers, the result of a division may also be a whole number. For example, 5 / 2 may show 2 instead of 2.5.
Frequently asked questions
Can I use more than one math sign in the same formula?
Yes. For example, [Net sales] - [Cost] - [Shipping] subtracts two fields at once. Use brackets to control the order, such as ([Net sales] - [Cost]) / [Net quantity].
Does trunc round my numbers? No. It cuts the number at the decimal place you choose. The digits after that are removed, not rounded.
Boolean Functions for Calculated Columns in Data Export
Boolean functions compare two values and give a simple answer: true or false. You can check whether one field is greater than, lesser than, or equal to another. Use these functions in the formula editor when you create a calculated column.
This article covers Boolean functions. For math, see Number Functions for Calculated Columns.
Example data used in this article
Every example below compares the same two fields, Net sales and Cost, for three products:
Coffee Mug
45
20
Canvas Tote Bag
30
30
Gift Card
10
15
Greater than ( > )
Returns true if the first value is greater than the second value. Otherwise, it returns false.
Syntax
Example: [Net sales] > [Cost] checks whether a product made a profit.
Coffee Mug
true
Canvas Tote Bag
false
Gift Card
false
Lesser than ( < )
Returns true if the first value is lesser than the second value. Otherwise, it returns false.
Syntax
Example: [Net sales] < [Cost] checks whether a product made a loss.
Coffee Mug
false
Canvas Tote Bag
false
Gift Card
true
Greater than or equal to ( >= )
Returns true if the first value is greater than or the same as the second value. Otherwise, it returns false.
Syntax
Example: [Net sales] >= [Cost] checks whether a product made a profit or broke even.
Coffee Mug
true
Canvas Tote Bag
true
Gift Card
false
Lesser than or equal to ( <= )
Returns true if the first value is lesser than or the same as the second value. Otherwise, it returns false.
Syntax
Example: [Net sales] <= [Cost] checks whether a product made a loss or broke even.
Coffee Mug
false
Canvas Tote Bag
true
Gift Card
true
Equal to ( = )
Returns true if both values are the same. Otherwise, it returns false.
Syntax
Example: [Net sales] = [Cost] checks whether a product broke even.
Coffee Mug
false
Canvas Tote Bag
true
Gift Card
false
Not equal to ( != )
Returns true if the two values are different. Otherwise, it returns false.
Syntax
Example: [Net sales] != [Cost] checks whether a product did not break even.
Coffee Mug
true
Canvas Tote Bag
false
Gift Card
true
Quick reference
>
Greater than
The first value is bigger
<
Lesser than
The first value is smaller
>=
Greater than or equal to
The first value is bigger or the same
<=
Lesser than or equal to
The first value is smaller or the same
=
Equal to
Both values are the same
!=
Not equal to
The values are different
Frequently asked questions
How do I use a Boolean column in my report? After you create it, you can filter on it. For example, filter a “Made a profit” column to show only rows that are true.
Can I compare a field to a fixed number?
Yes. Replace the second field with a number. For example, [Net quantity] > 5 returns true for every row with more than 5 items.
Date and Time Functions for Calculated Columns in Data Export
Date and time functions let you work with dates in your report. You can show today’s date, or pull out just the day, month, or year from a date field such as Order Date. Use these functions in the formula editor when you create a calculated column.
This article covers Date and Time functions. For comparisons, see Boolean Functions for Calculated Columns.
Example data used in this article
The examples below use the Order Date field for three orders:
#1001
2026-03-15
#1002
2026-07-04
#1003
2026-12-28
Show the current date
The current_date function shows today’s date. It updates each time the report runs, so the date always matches the day you view or export the report.
Syntax
Example: If you run the report on 2 November 2026, every row shows 2026-11-02.
This is useful for adding a “report date” column to exported files, so you know when the data was pulled.
Get the day from a date
The extract (day from ...) function pulls out only the day of the month, as a number from 1 to 31.
Syntax
Example
2026-03-15
15
2026-07-04
4
2026-12-28
28
Get the month from a date
The extract (month from ...) function pulls out only the month, as a number from 1 to 12. For example, 1 is January and 12 is December.
Syntax
Example
2026-03-15
3
2026-07-04
7
2026-12-28
12
This is useful for grouping or filtering orders by month, such as finding all orders placed in December.
Get the year from a date
The extract (year from ...) function pulls out only the year.
Syntax
Example
2026-03-15
2026
2026-07-04
2026
2026-12-28
2026
Use these functions with other date fields
The examples use Order Date, but you can use extract with any date field in your report. Replace [Order Date] with the field you need, such as [Created Date] or [Fulfillment Date].
Frequently asked questions
Why does the month show as a number and not a name?
The extract function always returns a number. For example, March shows as 3. This makes it easy to sort and filter by month.
Can I compare a date field to today’s date?
Yes. You can use current_date with a Boolean function. For example, [Order Date] < current_date returns true for every order placed before today.
Other Functions for Calculated Columns in Data Export
These functions help you clean up numbers and join text in a calculated column. Use trunc and round to control decimal places, float to store a number as a decimal value, and concat to join several fields into one. Use these functions in the formula editor when you create a calculated column.
What ::numeric means in these formulas
Some formulas below include ::numeric after the field name. This tells Data Export to treat the field as a number before it runs the function. Keep it in the formula as shown, or the function may not work.
Trunc: cut a number to a set number of decimal places
The trunc function removes extra decimal places from a number. It does not round. It simply cuts the number at the place you choose. The 2 in the formula means “keep 2 decimal places.” Change it to keep more or fewer.
Syntax
Example
45.6789
45.67
12.999
12.99
To remove all decimals, use 0 in place of 2. For example, 45.6789 becomes 45.
Round: round a number to a set number of decimal places
The round function rounds a number to the decimal places you choose. If the next digit is 5 or more, it rounds up. If it is 4 or less, it rounds down.
Syntax
Example
45.6789
45.68
12.344
12.34
Trunc or round: which one to use
Both functions limit decimal places, but they give different results:
45.6789
45.67
45.68
12.999
12.99
13.00
Use round for prices and totals you plan to share, since it gives the closest value. Use trunc when you never want a value to go up.
Float: store a number as a decimal value
The float function stores a number as an approximate decimal value. It can hold up to 53 digits of precision. Use it when you need decimals in a calculation but do not need the result to be exact to the last digit.
Syntax
For prices, totals, and other money values, use round instead. Float values are approximate, so they can show tiny differences, such as 0.30000000000000004 in place of 0.3.
Concat: join several fields into one
The concat function joins two or more fields or pieces of text into one value. Put ' ' (a space inside single quote marks) between fields to add a space between them.
Syntax
Example: Join First name and Last name into one column.
concat([First name],' ',[Last name])
Priya
Sharma
Priya Sharma
John
(empty)
John
Concat or ||: which one to use
Both join text, but they handle empty fields differently. Concat skips an empty field and still joins the rest. The || sign from the String functions can return an empty result if any field is empty. Use concat when some rows may have missing data.
Frequently asked questions
Why does my formula need ::numeric?
Some fields are stored in a way that trunc and round cannot work with directly. Adding ::numeric turns the field into a number first, so the function can run.
Can I put a different separator between fields in concat?
Yes. Put any text inside the single quote marks. For example, concat([City],', ',[Country]) gives “Bengaluru, India.”
Last updated