Order bys define how rows will be sorted in the response. For example, ordering rows by descending event count is one ordering, and ordering rows by the event name string is a different ordering.
JSON representation
{"desc": boolean,// Union field one_order_by can be only one of the following:"metric": {object (MetricOrderBy)},"dimension": {object (DimensionOrderBy)},"pivot": {object (PivotOrderBy)}// End of list of possible types for union field one_order_by.}
Fields
desc
boolean
If true, sorts by descending order.
Union field one_order_by. Specify one type of order by for OrderBy. one_order_by can be only one of the following:
Alphanumeric sort by Unicode code point. For example, "2" < "A" < "X" < "b" < "z".
CASE_INSENSITIVE_ALPHANUMERIC
Case insensitive alphanumeric sort by lower case Unicode code point. For example, "2" < "A" < "b" < "X" < "z".
NUMERIC
Dimension values are converted to numbers before sorting. For example in NUMERIC sort, "25" < "100", and in ALPHANUMERIC sort, "100" < "25". Non-numeric dimension values all have equal ordering value below all numeric values.
Used to select a dimension name and value pivot. If multiple pivot selections are given, the sort occurs on rows where all pivot selection dimension name and value pairs match the row's dimension name and value pair.
PivotSelection
A pair of dimension names and values. Rows with this dimension pivot pair are ordered by the metric's value.
For example if pivots = ('browser', 'Chrome') and metricName = "Sessions", then the rows will be sorted based on Sessions in Chrome.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-11-19 UTC."],[[["\u003cp\u003eOrderBys determine the sorting of rows in a response, based on metrics, dimensions, or pivots.\u003c/p\u003e\n"],["\u003cp\u003eYou can order by metrics (e.g., event count), dimensions (e.g., event name), or pivot column groups.\u003c/p\u003e\n"],["\u003cp\u003eSorting can be done in ascending or descending order, specified by the \u003ccode\u003edesc\u003c/code\u003e boolean field.\u003c/p\u003e\n"],["\u003cp\u003eDimension sorting offers alphanumeric, case-insensitive alphanumeric, and numeric order types.\u003c/p\u003e\n"],["\u003cp\u003ePivotOrderBy allows sorting within specific pivot column groups based on metric values.\u003c/p\u003e\n"]]],["This content details various methods for sorting data rows in a response, known as \"OrderBys.\" Sorting can be based on metrics (`MetricOrderBy`) or dimensions (`DimensionOrderBy`). Dimensions can be ordered alphanumerically, case-insensitively, or numerically (`OrderType`). `PivotOrderBy` allows sorting by metric values within pivot column groups, using `PivotSelection` to specify dimension-value pairs for focused sorting. `OrderBys` can also be applied in descending order, indicated by the `desc` field.\n"],null,["# OrderBy\n\n- [JSON representation](#SCHEMA_REPRESENTATION)\n- [MetricOrderBy](#MetricOrderBy)\n - [JSON representation](#MetricOrderBy.SCHEMA_REPRESENTATION)\n- [DimensionOrderBy](#DimensionOrderBy)\n - [JSON representation](#DimensionOrderBy.SCHEMA_REPRESENTATION)\n- [OrderType](#OrderType)\n- [PivotOrderBy](#PivotOrderBy)\n - [JSON representation](#PivotOrderBy.SCHEMA_REPRESENTATION)\n- [PivotSelection](#PivotSelection)\n - [JSON representation](#PivotSelection.SCHEMA_REPRESENTATION)\n\nOrder bys define how rows will be sorted in the response. For example, ordering rows by descending event count is one ordering, and ordering rows by the event name string is a different ordering.\n\n| JSON representation |\n|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"desc\": boolean, // Union field `one_order_by` can be only one of the following: \"metric\": { object (/analytics/devguides/reporting/data/v1/rest/v1beta/OrderBy#MetricOrderBy) }, \"dimension\": { object (/analytics/devguides/reporting/data/v1/rest/v1beta/OrderBy#DimensionOrderBy) }, \"pivot\": { object (/analytics/devguides/reporting/data/v1/rest/v1beta/OrderBy#PivotOrderBy) } // End of list of possible types for union field `one_order_by`. } ``` |\n\n| Fields ||\n|-------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `desc` | `boolean` If true, sorts by descending order. |\n| Union field `one_order_by`. Specify one type of order by for `OrderBy`. `one_order_by` can be only one of the following: ||\n| `metric` | `object (`[MetricOrderBy](/analytics/devguides/reporting/data/v1/rest/v1beta/OrderBy#MetricOrderBy)`)` Sorts results by a metric's values. |\n| `dimension` | `object (`[DimensionOrderBy](/analytics/devguides/reporting/data/v1/rest/v1beta/OrderBy#DimensionOrderBy)`)` Sorts results by a dimension's values. |\n| `pivot` | `object (`[PivotOrderBy](/analytics/devguides/reporting/data/v1/rest/v1beta/OrderBy#PivotOrderBy)`)` Sorts results by a metric's values within a pivot column group. |\n\nMetricOrderBy\n-------------\n\nSorts by metric values.\n\n| JSON representation |\n|----------------------------------|\n| ``` { \"metricName\": string } ``` |\n\n| Fields ||\n|----------------|----------------------------------------------------|\n| `metric``Name` | `string` A metric name in the request to order by. |\n\nDimensionOrderBy\n----------------\n\nSorts by dimension values.\n\n| JSON representation |\n|-------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"dimensionName\": string, \"orderType\": enum (/analytics/devguides/reporting/data/v1/rest/v1beta/OrderBy#OrderType) } ``` |\n\n| Fields ||\n|-------------------|----------------------------------------------------------------------------------------------------------------------------------------------|\n| `dimension``Name` | `string` A dimension name in the request to order by. |\n| `order``Type` | `enum (`[OrderType](/analytics/devguides/reporting/data/v1/rest/v1beta/OrderBy#OrderType)`)` Controls the rule for dimension value ordering. |\n\nOrderType\n---------\n\nRule to order the string dimension values by.\n\n| Enums ||\n|---------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `ORDER_TYPE_UNSPECIFIED` | Unspecified. |\n| `ALPHANUMERIC` | Alphanumeric sort by Unicode code point. For example, \"2\" \\\u003c \"A\" \\\u003c \"X\" \\\u003c \"b\" \\\u003c \"z\". |\n| `CASE_INSENSITIVE_ALPHANUMERIC` | Case insensitive alphanumeric sort by lower case Unicode code point. For example, \"2\" \\\u003c \"A\" \\\u003c \"b\" \\\u003c \"X\" \\\u003c \"z\". |\n| `NUMERIC` | Dimension values are converted to numbers before sorting. For example in NUMERIC sort, \"25\" \\\u003c \"100\", and in `ALPHANUMERIC` sort, \"100\" \\\u003c \"25\". Non-numeric dimension values all have equal ordering value below all numeric values. |\n\nPivotOrderBy\n------------\n\nSorts by a pivot column group.\n\n| JSON representation |\n|-------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"metricName\": string, \"pivotSelections\": [ { object (/analytics/devguides/reporting/data/v1/rest/v1beta/OrderBy#PivotSelection) } ] } ``` |\n\n| Fields ||\n|-----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `metric``Name` | `string` In the response to order by, order rows by this column. Must be a metric name from the request. |\n| `pivot``Selections[]` | `object (`[PivotSelection](/analytics/devguides/reporting/data/v1/rest/v1beta/OrderBy#PivotSelection)`)` Used to select a dimension name and value pivot. If multiple pivot selections are given, the sort occurs on rows where all pivot selection dimension name and value pairs match the row's dimension name and value pair. |\n\nPivotSelection\n--------------\n\nA pair of dimension names and values. Rows with this dimension pivot pair are ordered by the metric's value.\n\nFor example if pivots = ('browser', 'Chrome') and metricName = \"Sessions\", then the rows will be sorted based on Sessions in Chrome. \n\n ---------|----------|----------------|----------|----------------\n | Chrome | Chrome | Safari | Safari\n ---------|----------|----------------|----------|----------------\n Country | Sessions | Pages/Sessions | Sessions | Pages/Sessions\n ---------|----------|----------------|----------|----------------\n US | 2 | 2 | 3 | 1\n ---------|----------|----------------|----------|----------------\n Canada | 3 | 1 | 4 | 1\n ---------|----------|----------------|----------|----------------\n\n| JSON representation |\n|---------------------------------------------------------------|\n| ``` { \"dimensionName\": string, \"dimensionValue\": string } ``` |\n\n| Fields ||\n|--------------------|----------------------------------------------------------------|\n| `dimension``Name` | `string` Must be a dimension name from the request. |\n| `dimension``Value` | `string` Order by only when the named dimension is this value. |"]]