0
votes

I have a json object as below in Azure Dashboard:

{...,'Signal':'0.0',...}

where the Signal can take on the values of 0.0 for No and 1.0 for Yes. I wish to convert these values to "yes" and "no" using Kusto. I tried to do the following but it doesn't work:

| extend signal = tostring(replace(@"0.0",@"No",object['Signal']))

How do I fix this?

2

2 Answers

1
votes

Here is an example:

datatable(d:dynamic)[dynamic({'Signal':'0.0'})]
| extend Signal = replace('0.0', 'Yes',tostring(d.Signal))
1
votes

If you want to recreate the dynamic value with the value of Signal replaced with "yes"/"no"

You should extract the value of Signal, translate it to "yes"/"no" depending on the value, and then construct a new dynamic value, which contains the translated signal, and the rest of the properties in the original dynamic value, like this:

datatable(d:dynamic)[
    dynamic({'Signal':'0.0','AnotherSignal':'0.0'}),
    dynamic({'Signal':'1.0','AnotherSignal':'0.0'})
]
| project bag_merge(pack("Signal", iff(d.Signal == 0.0, "No", "Yes")), d)

Output:

Column1
{
"Signal": "No",
"AnotherSignal": "0.0"
}
{
"Signal": "Yes",
"AnotherSignal": "0.0"
}

If you want to extract the value of Signal, and replace it with "yes"/"no"

datatable(d:dynamic)[
    dynamic({'Signal':'0.0','AnotherSignal':'0.0'}),
    dynamic({'Signal':'1.0','AnotherSignal':'0.0'})
]
| extend UpdatedSignal = iff(d.Signal == 0.0, "No", "Yes")
d UpdatedSignal
{
"Signal": "0.0",
"AnotherSignal": "0.0"
}
No
{
"Signal": "1.0",
"AnotherSignal": "0.0"
}
Yes