Forum Discussion

reylui's avatar
reylui
Icon for Microsoft rankMicrosoft
Feb 21, 2022

Kusto Function Help Array_Sum, Array_Slice

Hi All, 

 

I am trying to partition an array in custom slices, then I would like to add all the sub arrays for each slice

 

Example - 

 

For a Table T defined below, I can do the following: 

 

let T = datatable(key: int,t:dynamic)

[

    1, dynamic([1,2,3,4,5,6,7, 8, 9, 10, 11, 12, 15, 26, 45]) // example array

];

T

| extend slices = array_split(t, dynamic([6, 12])) // custom slices

| mv-expand slices

| extend sum = array_sum(slices)

| summarize slices = make_list(sum)// sum the sub arrays

 

but now If I want to define this as a function and apply to all of the rows in my table I would like to do something like this:

 

let condense = (t:dynamic) {

| extend arr = array_split(t, dynamic([6, 12]))

| mv-expand arr

| extend sum = array_sum(arr)

| summarize arr = make_list(sum) // this can be a function

};

 

Does anyone have an idea on how to approach this problem ?

No RepliesBe the first to reply

Resources