Sub topic 8
Bucket fields for ad hoc categories
This chapter assumes you can build a summary report with a row grouping and a summarized field. You should know what a report type is and how filters narrow the rows. Matrix reports come in the next chapter, but the idea of a grouping is enough here.
What a bucket field is
A bucket field is a report-only column that sorts the values of an existing field into named categories. You define the categories inside the report builder. Salesforce evaluates them each time the report runs. You don't create a custom field, change the schema, or ask an administrator for anything.
Say your sales director wants opportunities grouped as Small, Medium, and Large. Those labels exist nowhere on the Opportunity object. A bucket field on Amount creates them for this report only, and you can then group by them like any other field.
Bucket fields are a good fit when the category is:
- needed for one report or a small family of reports,
- still being tested, so its boundaries might change next week, or
- owned by the report author, not by the data model.
If the same category is needed in list views, automation, page layouts, or SOQL, a formula field on the object is the better tool.
The three bucket types
The type of a bucket field follows the type of the source field you bucket.
| Source field type | Bucket type | You define a bucket by | Example |
|---|---|---|---|
| Number, currency, percent | Numeric | A range of values | Amount from 10,000 up to 50,000 becomes "Medium" |
| Picklist | Picklist | Selecting picklist values | Stages "Prospecting" and "Qualification" become "Early" |
| Text (such as Billing Country, Lead Source, Account Name) | Text | Selecting values that occur in the data | Several country names become "EMEA" |
Dates are not a bucket source. To group by month, quarter, or year, use the date grouping options instead, which already have built-in granularity.
Building one step by step
In Lightning report builder, with a summary report open on Opportunities:
- Open the Outline panel and find the Bucket Column option, or use the dropdown on a column header and choose Bucket this Column.
- Choose the Source Column. For the first example, use
Amount. - Give the bucket field a name, such as "Deal Size". This is the name that appears in the report and in the grouping list.
- Add buckets. For a numeric field, create one bucket per range and name it.
- Decide what to do with values that match no bucket (see the next section).
- Click Apply. The new column appears in the report, and you can drag it into the grouping area.
A numeric configuration might look like this:
Bucket field: Deal Size (source: Amount)
Small : less than 10,000
Medium : 10,000 to less than 50,000
Large : 50,000 or more
Unbucketed values: leave as "Other"Check how your org treats the boundary values. The usual behavior is that a lower bound is included and an upper bound is not. An opportunity of exactly 10,000 should therefore land in Medium, not Small. Run a test row at each boundary before you trust the report.
Values that match no bucket
Every row must end up somewhere. For values that you did not place in any bucket, Salesforce shows them under a catch-all named Other by default. You can rename this catch-all. You can also leave those values unbucketed so they keep their original value as their own group.
The choice matters for picklist and text sources. If you bucket only three stages out of ten, the other seven would either collapse into one "Other" group or appear as seven separate groups. Collapsing is usually what you want for a summary. Leaving them separate is better when you are exploring and don't know yet which values deserve a bucket.
A related edge case: a blank source value is not the same as a value you forgot. Rows with no Amount do not fall into any numeric range, so they appear under "Other" or as a blank group. Filter them out if they would distort the totals.
How bucket fields flow through a report
Order of evaluation matters. Filters decide which rows exist, then the bucket field labels them, then groupings and summaries run. A filter written on the bucket field applies to the label, not to the source value. If you filter on "Deal Size equals Large", you get exactly those rows whose source value falls in the Large range.
Using bucket fields in different formats
A bucket field is a column, so it works anywhere a column does.
- Tabular report. Add it as a column to see the label next to each row. You cannot group in a tabular report, so the bucket is only a label.
- Summary report. Drag it to the row grouping. You get one subtotal per bucket, with sum, average, minimum, maximum, and record count for whatever fields you summarize.
- Matrix report. Use it for row groupings, column groupings, or both. A matrix with "Deal Size" down the side and Stage across the top gives a compact two-dimensional view without a custom field.
- Joined report. Each block is built from its own report type. A bucket field belongs to the block's columns, so confirm the bucket exists in each block you want to compare. A common grouping across blocks needs the same field, and a bucket you created in one block is not automatically available in another.
A worked example
A team wants to know how much pipeline sits in each deal size, split by whether the deals are early or late stage.
- Create an Opportunity summary report filtered to open opportunities.
- Bucket
Amountinto "Deal Size" as above. - Bucket
Stageinto "Phase", with Early (Prospecting, Qualification), Late (Proposal, Negotiation), and leave the rest as Other. - Group rows by Deal Size.
- Summarize
Amountwith Sum and add Record Count. - Move Phase to the column grouping to convert the report to a matrix.
Now the same layout answers "how many large late-stage deals do we have, and what are they worth?" in one cell. No administrator created a field.
Bucket fields compared with the alternatives
| Need | Bucket field | Formula field on the object | Custom summary formula |
|---|---|---|---|
| Category visible only in one report | Good fit | Overkill | Not a categorizer |
| Category usable in list views and automation | Not available | Good fit | Not available |
| Category usable in SOQL | Not available | Good fit | Not available |
| Calculate a ratio across groups | Not possible | Possible per record | Good fit |
| Change boundaries without deployment | Yes, edit the report | Requires schema change | Yes |
Bucket fields classify rows. Custom summary formulas calculate across groups after rows are already grouped. The two work together: bucket first, then write AMOUNT:SUM / RowCount to get an average deal value per bucket.
Relating buckets to SOQL
SOQL has no bucketing construct, so the report layer is doing something a query cannot do in one statement. To reproduce the "Medium" bucket in a query, you filter on the range:
SELECT COUNT(Id) cnt, SUM(Amount) total
FROM Opportunity
WHERE IsClosed = false
AND Amount >= 10000
AND Amount < 50000Each bucket needs its own query like this, or you group on a stored field in SOQL and assign the labels in Apex or a client application. Note that the range uses >= for the lower bound and < for the upper, matching the usual bucket behavior.
Limits and gotchas
- Report-scoped. A bucket field exists only in the report that defines it. Cloning the report copies the bucket. Creating a new report does not.
- Quantity limits. Salesforce restricts the number of bucket fields per report, the number of buckets per field, and the number of values per bucket. The exact numbers have changed between releases, so read the current help article for your edition before designing a large category scheme.
- Source limits. Bucket fields cannot be built from every column. Some field types, and some summary or formula columns, are not eligible as a source.
- Text values. For text buckets you pick values that currently appear in the data. A new value that appears later falls into "Other" until someone edits the bucket.
- Dashboards. A dashboard component built from a report with a bucket field shows the bucket labels. If someone edits the bucket in the report, the dashboard changes at the next refresh.
- Naming. Bucket names appear in charts and axes. Keep them short and consistent across reports so users can compare.
Summary
Bucket fields let a report author create categories on the fly from number, picklist, and text columns. They are labels, not data, so they live and die with the report. Use them for quick, report-specific grouping. Move to a formula field once the category needs to exist everywhere.
Exercise
An Opportunity report has a numeric bucket field "Deal Size" with Small (less than 10,000), Medium (10,000 to less than 50,000), and Large (50,000 or more). One opportunity has an Amount of exactly 50,000, and another has a blank Amount. Where does each land, and what would you do about the blank one?
Show answer
The 50,000 opportunity lands in Large, because lower bounds are included and upper bounds are excluded. The blank-Amount opportunity matches no range, so it appears under "Other" (or as a blank group). If it would distort totals, add a filter that excludes opportunities where Amount equals nothing.
Exercise
Your manager wants "Region" (EMEA, Americas, APAC) available in list views and in an Apex query, built from Billing Country. Should you use a bucket field? Explain.
Show answer
No. A bucket field exists only inside one report and is not available to list views or SOQL. Create a formula field (or a picklist maintained by automation) on the object so the category is available everywhere.