I want to write kusto query that should basically return no results if three records are present in the variable. Here is an example:
let someValues = datatable (name: string)
[
"111",
"222",
"333",
];
// my query
So if the someValues
variable contains all the three strings - "111", "222", "333" then my query should return no results. If it contains only 2 of them "111", "222" then it should just return false. If it contains 1 of them "222" then also it should return false. But if it contains all three strings "111", "222", "333" then the query should not return any results.
Here is my attempt but it doesn't work.
let someValues = datatable (name: string)
[
"111",
"222",
"333",
];
someValues
| summarize make_set(name)
| where set_name contains "111" and set_name contains "222" and set_name contains "333" // this doesn't work because it outputs 1 row
Here is an equivalent C# program for that.
static void Main(string[] args)
{
List<string> s = new List<string>() {"111", "222", "333"};
if (s.Contains("111") && s.Contains("222") && s.Contains("333"))
return; // no results
else
{
Console.WriteLine("False"); // prints false
}
}
CodePudding user response:
let someValues = datatable (name: string)
[
"111",
"222",
"333"
];
let values = dynamic(["111", "222", "333"]);
someValues
| summarize make_set(name)
| project diff_is_empty_set = array_length(set_difference(values, set_name)) == 0
| where not(diff_is_empty_set)