I am attempting to create a function off of pivoted content which has dynamic content. An example of my scenario looks something like this:
let countActivities = (col: string) {
array_length(column_ifexists(col, dynamic([])))
};
let testdata = datatable(ActivityId: string, Message: string, SessionId: string)
["1", "abc", "100",
"2", "def", "100",
"2", "ghi", "100",
"4", "jkl", "100",
"1", "mno", "200"];
testdata
| extend iActivityId = toint(ActivityId)
| evaluate pivot(iActivityId, make_set(Message), SessionId)
| project SessionId,
Has1 = countActivities("1"),
Has2 = countActivities("2"),
Has3 = countActivities("3"),
Has4 = countActivities("4");
I'd like the above countActivities to return the number of elements in the array of a dynamic column, however the above causes the error columnifexists(): cannot be used in the function without tabular argument. I'd expect this to be a scalar function, so not certain how to provide a tabular argument in this scenario.
How should the above countActivities be written to allow this?