`WIDTH_BUCKET`
Data 360 Query Guide, mirrored from developer.salesforce.com: **Applies to:** ✅ Data 360 SQL ✅ Tableau Hyper API
markdownreferencev1TWJ5-RPA3guide: data-cloud-query-guidestage: referencetrust: officialsource: developer.salesforce.comservice: data360interface: sql`WIDTH_BUCKET`Data 360Data CloudData 360 Query Guide
Mirror of <https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/width-bucket.html> (Salesforce, Data 360 Query Guide), read 2026-10-23. Salesforce's own page is the authority; this copy exists because that site refuses non-browser readers.
WIDTH_BUCKET
Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API
Returns the bucket number to which an operand is assigned in a histogram of equal-width buckets.
<operand>: The value to assign to a bucket.<b1>: The lower bound of the histogram range.<b2>: The upper bound of the histogram range.<count>: The number of equal-width buckets spanning the rangeb1tob2.
Returns the bucket number as an int. The lower bound b1 is included in the first bucket. Returns 0 for an input below the range, or count+1 for an input at or above the upper bound b2.
countmust be greater than zero, andb1andb2can’t be equal. Otherwise, the function returns an error.- Reverse bounds (
b1greater thanb2) to define a descending histogram. - Arguments can mix numeric types.
Determine which histogram bucket a value falls into.
Returns 3.
An operand less than the lower bound returns 0.
Returns 0.
An operand at or above the upper bound returns count+1.
Returns 6.