project-reorder operator
Applies to: ✅ Microsoft Fabric ✅ Azure Data Explorer ✅ Azure Monitor ✅ Microsoft Sentinel
Reorders columns in the output table.
Syntax
T | project-reorder
ColumnNameOrPattern [asc
| desc
| granny-asc
| granny-desc
] [,
...]
Learn more about syntax conventions.
Parameters
Name | Type | Required | Description |
---|---|---|---|
T | string |
✔️ | The input tabular data. |
ColumnNameOrPattern | string |
✔️ | The name of the column or column wildcard pattern by which to order the columns. |
asc , desc , granny-asc , granny-desc |
string |
Indicates how to order the columns when a wildcard pattern is used. asc or desc orders columns by column 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, a100 comes before a20 when granny-asc is specified. |
Note
- If no explicit ordering is specified, the order is determined by the matching columns as they appear in the source table.
- In ambiguous ColumnNameOrPattern matching, the column appears in the first position matching the pattern.
- Specifying columns for the
project-reorder
is optional. Columns that aren't specified explicitly appear as the last columns of the output table. - To remove columns, use
project-away
. - To choose which columns to keep, use
project-keep
. - To rename columns, use
project-rename
.
Returns
A table that contains columns in the order specified by the operator arguments. project-reorder
doesn't rename or remove columns from the table, therefore, all columns that existed in the source table, appear in the result table.
Examples
The examples in this section show how to use the syntax to help you get started.
The examples in this article use publicly available tables in the help cluster, such as the
StormEvents
table in the Samples database.
The examples in this article use publicly available tables, such as the
StormEvents
table in the Weather analytics sample data.
Reorder with b first
Reorder a table with three columns (a, b, c) so the second column (b) will appear first.
print a='a', b='b', c='c'
| project-reorder b
Output
b | a | c |
---|---|---|
b | a | c |
Reorder with a first
Reorder columns of a table so that columns starting with a
will appear before other columns.
print b = 'b', a2='a2', a3='a3', a1='a1'
| project-reorder a* asc
Output
a1 | a2 | a3 | b |
---|---|---|---|
a1 | a2 | a3 | b |