I would like to sort the results of my query according to customDimension.MyCustomProperty
which is present in all entities and is a number. How can I do that?
Asked
Active
Viewed 4.0k times
45

John Gardner
- 24,225
- 5
- 58
- 76

Leonardo
- 10,737
- 10
- 62
- 155
1 Answers
80
What I would suggest is first extend
ing your result set with your customDimension. Then you'll have to cast your new column to either a string, an int or a double. The reason for this is that customDimensions
is considered a dynamic column
A quick example:
traces
| extend sortKey = toint(customDimensions.MyCustomProperty)
| order by sortKey asc
The casting options are:
- tostring()
- toint()
- todouble()
If you want to remove the sorting key after the actual sort, you can project-away
the new column.

Eric Lee
- 8,181
- 4
- 21
- 18

Yannick Meeus
- 5,643
- 1
- 35
- 34
-
11note: you only need to use that `['blah']` syntax if your custom dimension (or measurement) contains special characters. otherwise you can just do `customDimensions.MyCustomProperty`. also, *generally* if the value is numeric, you should put it in customMeasurements instead, customDimensions are treated as strings by processing – John Gardner Apr 14 '17 at 19:55
-
@JohnGardner Fair enough, I'll edit the usage of [''...] out. I also did not know about customMeasurements vs customDimensions. You've given me some reading up to do, so thanks for that :) – Yannick Meeus Apr 14 '17 at 21:06
-
Why arent any of my custom properties in customDimensions when logging to appInsights? – Brunis Jul 10 '20 at 09:06