|
| 1 | +--- |
| 2 | +title: 'project-reorder' |
| 3 | +description: 'This page explains how to reorder specified fields in the output.' |
| 4 | +tags: |
| 5 | + ['axiom documentation', 'documentation', 'axiom', 'tabular operators', 'project-reorder'] |
| 6 | +--- |
| 7 | + |
| 8 | +Reorders specified fields in the output while keeping the original order of unspecified fields. |
| 9 | + |
| 10 | +## Syntax |
| 11 | + |
| 12 | +```kusto |
| 13 | +| project-reorder FieldName1OrWildcard[*] [asc|desc|granny-asc|granny-desc], FieldName2OrWildcard[*], FieldName3OrWildcard [direction], ... |
| 14 | +``` |
| 15 | + |
| 16 | +## Arguments |
| 17 | + |
| 18 | +| **name** | **type** | **description** | |
| 19 | +| --------------------- | ------------ | ------------------------------------------------------ | |
| 20 | +| Field Name | **string** | The name of the field to be reordered in the output. | |
| 21 | +| [direction] | **string** | Optional. Specifies the sort order for the reordered fields. Can be one of: `asc`, `desc`, `granny-asc`, or `granny-desc`. `asc` or `desc` orders fields by field name in ascending or descending manner, respectively. `granny-asc` or `granny-desc` orders by ascending or descending, respectively, while secondarily sorting by the next numeric value. For example, `b50` comes before `b9` when granny-asc is specified.| |
| 22 | + |
| 23 | +## Returns |
| 24 | + |
| 25 | +A table with the specified fields reordered as requested, followed by any unspecified fields in their original order. `project-reorder` doesn‘t rename or remove fields from the dataset, therefore, all fields that existed in the dataset, appear in the result table. |
| 26 | + |
| 27 | +## Examples |
| 28 | + |
| 29 | +Reorder all fields in ascending order: |
| 30 | + |
| 31 | +```kusto |
| 32 | +['sample-http-logs'] |
| 33 | +| project-reorder * asc |
| 34 | +``` |
| 35 | + |
| 36 | +[Run in Playground](https://play.axiom.co/axiom-play-qf1k/explorer?initForm=%7B%22apl%22%3A%20%22%5B%27sample-http-logs%27%5D%5Cn%7C%20project-reorder%20%2A%20asc%22%7D) |
| 37 | + |
| 38 | +Reorder specific fields to the beginning: |
| 39 | + |
| 40 | +```kusto |
| 41 | +['sample-http-logs'] |
| 42 | +| project-reorder method, status, uri |
| 43 | +``` |
| 44 | + |
| 45 | +[Run in Playground](https://play.axiom.co/axiom-play-qf1k/explorer?initForm=%7B%22apl%22%3A%20%22%5B%27sample-http-logs%27%5D%5Cn%7C%20project-reorder%20method%2C%20status%2C%20uri%22%7D) |
| 46 | + |
| 47 | +Reorder fields using wildcards and sort in descending order: |
| 48 | + |
| 49 | +```kusto |
| 50 | +['github-push-event'] |
| 51 | +| project-reorder repo*, num_commits, push_id, ref, size, ['id'], size_large desc |
| 52 | +``` |
| 53 | + |
| 54 | +[Run in Playground](https://play.axiom.co/axiom-play-qf1k/explorer?initForm=%7B%22apl%22%3A%20%22%5B%27github-push-event%27%5D%5Cn%7C%20project-reorder%20repo%2A%2C%20num_commits%2C%20push_id%2C%20ref%2C%20size%2C%20%5B%27id%27%5D%2C%20size_large%20desc%22%7D) |
| 55 | + |
| 56 | +Reorder specific fields and keep others in original order: |
| 57 | + |
| 58 | +```kusto |
| 59 | +['otel-demo-traces'] |
| 60 | +| project-reorder trace_id, *, span_id // orders the trace_id then everything else, then span_id fields |
| 61 | +``` |
| 62 | + |
| 63 | +[Run in Playground](https://play.axiom.co/axiom-play-qf1k/explorer?initForm=%7B%22apl%22%3A%20%22%5B%27otel-demo-traces%27%5D%5Cn%7C%20project-reorder%20trace_id%2C%20%2A%2C%20span_id%22%7D) |
0 commit comments