Wypróbuj serwer MCP w Google Analytics. Zainstaluj go z
GitHub. Więcej informacji znajdziesz w
ogłoszeniu.
OrderBy
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Sortowanie według określa, jak wiersze będą sortowane w odpowiedzi. Na przykład sortowanie wierszy według malejącej liczby zdarzeń to jedno uporządkowanie, a sortowanie według ciągu znaków nazwy zdarzenia to inne uporządkowanie.
Zapis JSON |
{
"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 .
} |
Pola |
desc |
boolean
Jeśli jest ustawiona na wartość Prawda, sortuje w kolejności malejącej.
|
Pole unii one_order_by . Określ jeden typ sortowania w przypadku kolumny OrderBy . one_order_by może być tylko jednym z tych elementów: |
metric |
object (MetricOrderBy )
Sortuje wyniki według wartości danych.
|
dimension |
object (DimensionOrderBy )
Sortuje wyniki według wartości wymiaru.
|
pivot |
object (PivotOrderBy )
Sortuje wyniki według wartości danych w grupie kolumn przestawnych.
|
MetricOrderBy
Sortowanie według wartości danych.
Zapis JSON |
{
"metricName": string
} |
Pola |
metricName |
string
Nazwa danych w prośbie, według których mają być one posortowane.
|
DimensionOrderBy
Sortuje według wartości wymiaru.
Zapis JSON |
{
"dimensionName": string,
"orderType": enum (OrderType )
} |
Pola |
dimensionName |
string
Nazwa wymiaru w pytaniu, według którego mają być sortowane dane.
|
orderType |
enum (OrderType )
Określa regułę sortowania wartości wymiaru.
|
OrderType
Reguła służąca do sortowania wartości wymiaru ciągu znaków.
Wartości w polu enum |
ORDER_TYPE_UNSPECIFIED |
Nie określono. |
ALPHANUMERIC |
Sortowanie alfanumeryczne według punktu kodowego Unicode. Na przykład „2” < „A” < „X” < „b” < „z”. |
CASE_INSENSITIVE_ALPHANUMERIC |
Sortowanie bez uwzględniania wielkości liter według znaków alfanumerycznych według małych liter w punkcie kodowym Unicode. Na przykład „2” < „A” < „b” < „X” < „z”. |
NUMERIC |
Wartości wymiarów są konwertowane na liczby przed posortowaniem. Na przykład w sortowaniu NUMERYCZNYM „25” < „100”, a w sortowaniu ARYTMETYCZNYM „100” < „25”.ALPHANUMERIC Wartości wymiarów niebędących liczbami mają tę samą wartość sortowania niż wszystkie wartości liczbowe. |
PivotOrderBy
Sortuje według grupy kolumn tabeli przestawnej.
Zapis JSON |
{
"metricName": string,
"pivotSelections": [
{
object (PivotSelection )
}
]
} |
Pola |
metricName |
string
W odpowiedzi na order by sortuj wiersze według tej kolumny. Musi być nazwą wskaźnika z zapytania.
|
pivotSelections[] |
object (PivotSelection )
Służy do wybierania nazwy wymiaru i wartości przekształcenia. Jeśli podano wiele elementów wyboru, sortowanie odbywa się w wierszach, w których wszystkie pary nazwa i wartość wymiaru elementu wyboru są zgodne z parą nazwa i wartość wymiaru wiersza.
|
PivotSelection
Para nazw i wartości wymiarów. Wiersze z tą parą wymiarów są uporządkowane według wartości danych.
Jeśli na przykład pivots = („browser”, „Chrome”) i metricName = „Sessions”, wiersze zostaną posortowane według sesji w Chrome.
---------|----------|----------------|----------|----------------
| Chrome | Chrome | Safari | Safari
---------|----------|----------------|----------|----------------
Country | Sessions | Pages/Sessions | Sessions | Pages/Sessions
---------|----------|----------------|----------|----------------
US | 2 | 2 | 3 | 1
---------|----------|----------------|----------|----------------
Canada | 3 | 1 | 4 | 1
---------|----------|----------------|----------|----------------
Zapis JSON |
{
"dimensionName": string,
"dimensionValue": string
} |
Pola |
dimensionName |
string
Musi być nazwą wymiaru z zapytania.
|
dimensionValue |
string
Sortowanie według tylko wtedy, gdy wymiar nazwany ma tę wartość.
|
O ile nie stwierdzono inaczej, treść tej strony jest objęta licencją Creative Commons – uznanie autorstwa 4.0, a fragmenty kodu są dostępne na licencji Apache 2.0. Szczegółowe informacje na ten temat zawierają zasady dotyczące witryny Google Developers. Java jest zastrzeżonym znakiem towarowym firmy Oracle i jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-07-26 UTC.
[null,null,["Ostatnia aktualizacja: 2025-07-26 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. |"]]