Skip to main content
Help & Documentation

Calculations for common jobs

Ready-to-paste formulas for order size buckets, customer lifetime value, shipping times, fiscal quarters, weekdays, name cleanup and net sales.

15 min readUpdated November 22, 2026

These are the calculations teams build most often, each with the formula, what it gives you and a real preview. Paste one into the Formula box, swap in your own field names, and check it against your rows.

The preview for Order Size: the formula IF(Sales >= 500, "Large", IF(Sales >= 100, "Medium", "Small")) marked Valid, the summary Text · Small (32), Medium (10), Large (8), and a table of Sales values next to their Small, Medium or Large label

When to use it

  • A weekly sales review that splits revenue by order size and by customer value.
  • An operations dashboard that tracks shipping speed in business days and flags late orders.
  • A finance report that rolls up by fiscal quarter instead of calendar quarter.
  • A cleanup pass on a messy export before anyone builds a chart from it.

Every recipe below came from the Superstore sample dataset. Your field names will differ; the [ suggestions in the editor fill them in.

Sales

Order size buckets

Group orders into Large, Medium and Small so you can color or filter a chart by size.

IF([Sales] >= 500, "Large", IF([Sales] >= 100, "Medium", "Small"))

Put the biggest threshold first. IF stops at the first condition that holds, so a $2,573 order is Large and never reaches the Medium test.

Net sales after discount

[Sales] * (1 - [Discount])
Net Sales computed for real rows: 16.448 with a 0.2 discount becomes 13.16, 3.54 with 0.8 becomes 0.71, and rows with no discount stay the same

Set Display format to Currency so it reads as money everywhere.

Profit margin

SAFE_DIVIDE(SUM([Profit]), SUM([Sales]))

Set the format to Percentage. SAFE_DIVIDE gives a blank instead of an error when sales are 0. Because it adds up first, each bar on a chart shows its true margin.

Customers

Customer lifetime sales

Every order row gets its customer's total sales, so you can bucket customers by value or filter to your top accounts.

FOREACH([Customer ID], SUM([Sales]))
Customer Lifetime Sales next to each order: customer PO-19195's three orders of 3.54, 11.784 and 272.736 each show 288.06, and ME-17320's two orders each show 4,374.88

Wrap it in IF to label customers: IF(FOREACH([Customer ID], SUM([Sales])) >= 5000, "Key account", "Standard"). A field built on FOREACH can go on Rows, Columns or Color like any category.

First name

SPLIT([Customer Name], " ", 1)
First Name split from Customer Name: Darren Powers becomes Darren, Phillina Ober becomes Phillina, Jack O'Briant becomes Jack

Use 2 for the second word. SPLIT isn't available on every data source; on an uploaded file it always works.

Operations

Business days to ship

BUSINESSDAYS([Order Date], [Ship Date])
Business Days to Ship for real orders: Jan 5 to Jan 12, 2022 is 5 days, Jan 6 to Jan 10 is 2 days, and Jan 6 to Jan 7 is 1 day

Weekends don't count, so an order placed Friday and shipped Monday took 1 business day. For calendar days, use DATEDIFF("day", [Order Date], [Ship Date]).

Late or on time

IF(DATEDIFF("day", [Order Date], [Ship Date]) > 4, "Late", "On time")

Change the 4 to your service level. Click a row, then Explain calc, to see which dates produced the label.

Days since last order

DATEDIFF("day", MAX([Order Date]), TODAY())

On a table by customer, it shows how many days ago each customer last ordered. TODAY() moves every day, so the number stays current.

Dates and calendars

Fiscal quarter label

CONCAT("FY", STR(DATEPART("fiscalyear", [Order Date])), " Q", STR(DATEPART("fiscalquarter", [Order Date])))
Fiscal Quarter computed as FY2022 Q1 for orders placed in January 2022

The fiscal year follows your account's fiscal year start. STR turns the numbers into text so CONCAT can join them.

Day of the week

DAYNAME([Order Date])
Order Weekday for real orders: Jan 3, 2022 is Monday, Jan 4 is Tuesday, Jan 6 is Thursday, with the summary Thursday (27), Sunday (6), Tuesday (5)

Put it on an axis to see which days are busiest. Use DATEPART("weekday", [Order Date]) when you want a number to sort by.

Start of the month

DATETRUNC("month", [Signup Date])

Every date in a month becomes the 1st, which makes a clean cohort field for "customers who signed up in March."

Cleanup

JobFormula
Trim stray spacesTRIM([Name])
Make codes matchUPPER([Product Code])
Fill blank discounts with 0COALESCE([Discount], 0)
Treat "Unknown" as blankNULLIF([Status], "Unknown")
City and state in one labelCONCAT([City], ", ", [State])
First 3 digits of a ZIP codeLEFT([Postal Code], 3)
Read text like 03/15/2025 as a dateDATE([Order Text], "MM/DD/YYYY")

Do it from chat

Describe the job and let the analyst write the formula:

Add a field that labels orders Large over $500, Medium over $100, and Small otherwise
Add a field for each customer's lifetime sales
Add a fiscal quarter field like FY2025 Q3

FAQ

Can I use one of these inside another calculated field? Yes. Once saved, a calculated field shows up in the Fields list and in the [ suggestions like any other field.

Why does my margin look different on a chart than in the preview? A formula with SUM gives one value per group. The preview works it out over the sample; the chart works it out for each bar.

Where do I find all the functions? See Calculation function reference.