Bin (PQL)
Returns the bins for a column
- Returned Output: Numeric
- Library: PQL \ Granular \ Math
- Version: 2023.00.000
- Compatibility: Pyramid Query Language (PQL) data sources
Syntax
Bin( <Column Number> , <Numeric> )
* Click on the function's arguments above for more details on the input values.
Comments
- The column needs to be an attribute with numerical values in the model.
- The math operations are not running on measures (aka 'values' or 'metrics'). They are operating on atomic items in the attribute / column itself. These values can then be subsequently used to drive an aggregated metric.
- For details on how to employ and use this function see the custom column overview.
Different Function types
- This function is similar to the PQL common functions of the same name. However, it operates on a column directly at the grain.
- As a granular function, it is used in the base SQL query itself.
Example
This example uses the BIN function to categorize numerical amounts into bins, with each bin representing a range of 100 units.
Description
- The BIN function groups the values in the Amount column into increments of 100.
- The result is that values will be placed into bins like 0, 100, 200, 300, etc., depending on which range they fall into.
Bin([Mathops].[Amount], 100)
Example Output
- If the Amount is 23, it will fall into the bin starting at 0 (0-99).
- If the Amount is 142, it will fall into the bin starting at 100 (100-199).
- If the Amount is 368, it will fall into the bin starting at 300 (300-399).
You can see the effect from this example snippet in column #2- Bin, based on the source column in position #3 - Amount: