Is there a way to convert from hex in Kusto? I see a scalar function to convert to hex, but I want to convert from hex.
https://learn.microsoft.com/en-us/azure/kusto/query/tohexfunction
Is there a way to convert from hex in Kusto? I see a scalar function to convert to hex, but I want to convert from hex.
https://learn.microsoft.com/en-us/azure/kusto/query/tohexfunction
you can use hex value for long literal, for example:
print long(0x123)
see more here: https://learn.microsoft.com/en-us/azure/kusto/query/scalar-data-types/long
(Posting to old thread if anyone finds this in the future.)
let T = datatable(Value:string) [
'A2FF',
'BEAD',
'CAFE',
'FACE',
'C0C0'
];
T
| extend ValueExtracted = extract_all('(.)', reverse(Value))
| mv-expand ValueExtracted
| serialize
| extend ValueIndex = indexof('0123456789ABCDEF', ValueExtracted, 0)
| extend ValuePow = row_number(0, prev(Value) != Value)
| extend ValueDig = pow(16, ValuePow) * ValueIndex
| summarize ValueComplete = sum(ValueDig) by Value
| extend ToHexCalc = tohex(toint(ValueComplete))
Granted it isn't pretty but it seems to work for at least this data set. An inbuit function would be so much better I agree.
Output:
[Value, ValueComplete, ToHexCalc
A2FF, 41727, a2ff
BEAD, 48813, bead
CAFE, 51966, cafe
FACE, 64206, face
C0C0, 49344, c0c0][1]
Arriving late to the party...
print character = make_string(tolong('0x22'))
character |
---|
" |