You can include User Defined Fields, such as ranges and quantiles, in your table query by:
-
Adding a
udfssection; use this to define the structure of the UDF. -
Adding your UDF to the
dimensions.
For more details about range and quantile UDFs, see Ranges and Quantiles.
Range UDFs
Following is an example of a table query that defines a range UDF:
{
"database" : "str:database:bank",
"measures" : [ "str:count:bank:F_Customer" ],
"udfs": {
"myRange":{
"type": "RANGE",
"from": 1,
"to": 500,
"increment": 100,
"measure": "str:measure:bank:F_Customer:Cust_Profit",
"label": "My Range",
"toInclusive": true
}
},
"dimensions" : [
[ "str:field:bank:F_Customer:Gender" ], [ "str:udf:myRange" ]
]
}
Where:
|
myRange |
This is an ID for the UDF; you can replace it with any string. You need to use this ID in the |
||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
type |
Set to |
||||||||||||||
|
from |
The starting value for the set of ranges. |
||||||||||||||
|
to |
The end value for the set of ranges. |
||||||||||||||
|
increment |
The size of each range. |
||||||||||||||
|
measure |
The Open Data ID of the measure you want to create a range for. This needs to match the ID format this is returned by the |
||||||||||||||
|
label |
A label (display name) for the UDF that will be returned in the query results. |
||||||||||||||
|
toInclusive |
Set this to either
|
Quantile UDFs
Following is an example of a table query that defines a quantile UDF:
{
"database" : "str:database:bank",
"measures" : [ "str:count:bank:F_Customer" ],
"udfs": {
"myRange": {
"type": "QUANTILE",
"label": "My Quantile",
"measure": "str:measure:bank:F_Customer:Cust_Profit",
"distribution": "str:count:bank:F_Customer",
"ranges": 5
}
},
"dimensions" : [
[ "str:field:bank:F_Customer:Gender" ], [ "str:udf:myRange" ]
]
}
Where:
|
myRange |
This is an ID for the UDF; you can replace it with any string. You need to use this ID in the |
|---|---|
|
type |
Set to |
|
label |
A label (display name) for the UDF that will be returned in the query results. |
|
measure |
The Open Data ID of the measure you want to create a quantile for. This needs to match the ID format this is returned by the |
|
distribution |
The measure or count to use to determine the distribution of the quantile. This can be any measure or count, but must return positive values for all records. It is equivalent to the Equal Distribution Of setting in SuperWEB2. See Ranges and Quantilesfor more details. |
|
ranges |
The number of quantile ranges to create. By default you can choose between 2 and 10, but these limits can be configured by the administrator on a per-dataset basis using the SuperADMIN . |