make-series does not allow variable reference for range

%3CLINGO-SUB%20id%3D%22lingo-sub-241107%22%20slang%3D%22en-US%22%3Emake-series%20does%20not%20allow%20variable%20reference%20for%20range%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-241107%22%20slang%3D%22en-US%22%3E%3CP%3ETake%20this%20example%3A%3C%2FP%3E%3CPRE%3Elet%20T%20%3D%20datatable(x%3A%20int%2C%20group%3A%20string)%20%5B%3CBR%20%2F%3E%2023%2C%20%22red%22%2C%3CBR%20%2F%3E%2044%2C%20%22red%22%2C%3CBR%20%2F%3E%2055%2C%20%22red%22%2C%3CBR%20%2F%3E%2066%2C%20%22red%22%2C%3CBR%20%2F%3E%2011%2C%20%22green%22%2C%3CBR%20%2F%3E%2043%2C%20%22blue%22%3CBR%20%2F%3E%5D%3B%3CBR%20%2F%3ET%20%7C%20make-series%20avg(x)%20on%20x%20in%20range(0%2C100%2C20)%20by%20group%3C%2FPRE%3E%3CP%3EIt%20works%20fine...%3C%2FP%3E%3CP%3EBut%20if%20I%20want%20to%20use%20a%20variable%20to%20hold%20the%20range%2C%20it%20fails%20with%20syntax%20error...%3C%2FP%3E%3CPRE%3Elet%20R%20%3D%20range(0%2C100%2C20)%3B%3CBR%20%2F%3Elet%20T%20%3D%20datatable(x%3A%20int%2C%20group%3A%20string)%20%5B%3CBR%20%2F%3E%2023%2C%20%22red%22%2C%3CBR%20%2F%3E%2044%2C%20%22red%22%2C%3CBR%20%2F%3E%2055%2C%20%22red%22%2C%3CBR%20%2F%3E%2066%2C%20%22red%22%2C%3CBR%20%2F%3E%2011%2C%20%22green%22%2C%3CBR%20%2F%3E%2043%2C%20%22blue%22%3CBR%20%2F%3E%5D%3B%3CBR%20%2F%3ET%20%7C%20make-series%20avg(x)%20on%20x%20in%20R%20by%20group%3C%2FPRE%3E%3CP%3EIs%20this%20expected%20behavior%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-241107%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20Log%20Analytics%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EQuery%20Language%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-242026%22%20slang%3D%22en-US%22%3ERe%3A%20make-series%20does%20not%20allow%20variable%20reference%20for%20range%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-242026%22%20slang%3D%22en-US%22%3E%3CP%3EMy%20understanding%20of%20the%20language%20that%20this%20is%20intentional.%20You%20cannot%20replace%20whole%20operators.%20You%20can%20this%20though%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3Elet%20firstNum%20%3D%200%3B%0Alet%20secondNum%20%3D%20100%3B%0Alet%20thirdNum%20%3D%2020%3B%0Alet%20T%20%3D%20datatable(x%3A%20int%2C%20group%3A%20string)%20%5B%0A%2023%2C%20%22red%22%2C%0A%2044%2C%20%22red%22%2C%0A%2055%2C%20%22red%22%2C%0A%2066%2C%20%22red%22%2C%0A%2011%2C%20%22green%22%2C%0A%2043%2C%20%22blue%22%0A%5D%3B%0AT%20%7C%20make-series%20avg(x)%20on%20x%20in%20range(firstNum%2CsecondNum%2CthirdNum)%20%20by%20group%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
Contributor

Take this example:

let T = datatable(x: int, group: string) [
23, "red",
44, "red",
55, "red",
66, "red",
11, "green",
43, "blue"
];
T | make-series avg(x) on x in range(0,100,20) by group

It works fine...

But if I want to use a variable to hold the range, it fails with syntax error...

let R = range(0,100,20);
let T = datatable(x: int, group: string) [
23, "red",
44, "red",
55, "red",
66, "red",
11, "green",
43, "blue"
];
T | make-series avg(x) on x in R by group

Is this expected behavior?

1 Reply

My understanding of the language that this is intentional. You cannot replace whole operators. You can this though:

 

let firstNum = 0;
let secondNum = 100;
let thirdNum = 20;
let T = datatable(x: int, group: string) [
 23, "red",
 44, "red",
 55, "red",
 66, "red",
 11, "green",
 43, "blue"
];
T | make-series avg(x) on x in range(firstNum,secondNum,thirdNum)  by group