I have a table in kusto with 13,000 rows. I would like to know how can I create a new column in this table which fill it with only 2 values (0 and 1) randomly. Is there also a possibility to create a column containing 3 different value of data type: string ?
Asked
Active
Viewed 1,630 times
1 Answers
4
you can extend a calculated column using the rand()
function: https://learn.microsoft.com/en-us/azure/data-explorer/kusto/query/randfunction
for example:
0
or1
:| extend y = toint(rand(1) > 0.5)
1 of 3 strings (
first
,second
orthird
):| extend r = rand(3) | extend s = case(r <= 0, "first", r <= 1, "second", "third") | project-away r
if you need to do this at ingestion time, you can use an update policy: https://learn.microsoft.com/en-us/azure/data-explorer/kusto/management/updatepolicy
or if you want to do this for the existing table, you can use a .set-or-replace
command: https://learn.microsoft.com/en-us/azure/data-explorer/kusto/management/data-ingestion/ingest-from-query

Yoni L.
- 22,627
- 2
- 29
- 48