Forum Discussion
Pivot sort
- Jan 13, 2020
hdsheena , ScottAllison - you can now use project-reorder to set the order you want, and if column names are not known (since the data set here is dynamic) you can use asc / desc.
Seconding the enhancement request, and thank you for this post as it was exactly what I was looking for!
hdsheena , ScottAllison - you can now use project-reorder to set the order you want, and if column names are not known (since the data set here is dynamic) you can use asc / desc.
- Akash_HandeJan 26, 2022Copper Contributor
Working with similar kind of problem with below query:
availabilityResults| where timestamp < now(5d)| summarize successCount = count(success) by bin(timestamp, 1h)| project date_of_month = format_datetime(timestamp, 'yyyy-MM-dd'), hour = strcat("Hour", datetime_part("hour", timestamp)), successCount| evaluate pivot(hour, sum(successCount))Here I gets result like below (column names)date_of_month | Hour0 | Hour1 | Hour10 | Hour11 ....... Hour9
What I expect:
date_of_month | Hour0 | Hour1 | Hour2 | Hour3 ...... Hour23
If I try to use column name like Hour0.... Hour23 getting below error
project-reorder: Failed to resolve attribute as a column entity: Hour0
- Clive_WatsonJan 27, 2022Bronze Contributor
You can use granny_asc now https://docs.microsoft.com/en-gb/azure/data-explorer/kusto/query/projectreorderoperator
Heartbeat | summarize successCount = count(Computer) by bin(TimeGenerated, 1h) | project date_of_month = format_datetime(TimeGenerated, 'yyyy-MM-dd'), hour = strcat("Hour", datetime_part("hour", TimeGenerated)), successCount | evaluate pivot(hour, sum(successCount)) | project-reorder date_*, Hour* granny-ascResult: