*Capping* a weight refers to limiting the maximum value that a weight can take. For example, where weights are *capped* at 5 it means that any weight computed to be greater than 5 is returned as 5.

## Requirements

- A weight variable

## Method

- From the toolbar, select
**Anything > Data > Variables > New > Custom Code > JavaScript - Numeric**. - Add appropriate entries for
**Name**and**Label.** - Set
**Expression**to:

where`Math.min(maxValue,weightVariable)``weightVariable`is the name of the variable that is the current weight and`maxValue`is the maximum value that you wish the weight to take (i.e., the*cap*). - Check
**Usable as a weight**for the new weight variable. - Apply the newly created weight to any tables and/or charts to be weighted.

## Next

How to Use Frequency Weights in Q

How to Create Weights With Different Categories Merged

How to Configure a Weight from Variable(s)