Home

Accessing a column from within toscalar() - Log Analytics Query Language

%3CLINGO-SUB%20id%3D%22lingo-sub-213136%22%20slang%3D%22en-US%22%3EAccessing%20a%20column%20from%20within%20toscalar()%20-%20Log%20Analytics%20Query%20Language%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-213136%22%20slang%3D%22en-US%22%3E%3CP%3ESpeaking%20in%20terms%20of%20C%2C%20I%20need%20to%20do%20something%20like%20this%3A%3C%2FP%3E%3CBLOCKQUOTE%3E%3CP%3Efor(i%20%3D%200%3B%20i%20%26lt%3B%2030%3B%20i%2B%2B)%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3Bsubquery(i)%3B%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3C%2FBLOCKQUOTE%3E%3CP%3EThe%20subquery%20returns%20a%20table%20with%20a%20single%20cell.%20I%20am%20trying%20to%20do%20something%20like%20this%3A%3C%2FP%3E%3CBLOCKQUOTE%3E%3CP%3Erange%20offset%20from%201%20to%2030%20step%201%3CBR%20%2F%3E%7C%20project%20Column%20%3D%20toscalar(%20range%20index%20from%201%20to%2030%20step%201%20%7C%20where%20index%20%3D%3D%20offset)%3C%2FP%3E%3C%2FBLOCKQUOTE%3E%3CP%3EBut%20the%20%3CEM%3Eoffset%3C%2FEM%3E%20in%20the%20%3CEM%3Etoscalar()%3C%2FEM%3E%20is%20not%20being%20recognized%3B%20I'm%20getting%20the%20following%20error%3A%26nbsp%3B%3CSTRONG%3E'where'%20operator%3A%20Failed%20to%20resolve%20column%20or%20scalar%20expression%20named%20'offset'.%26nbsp%3B%3C%2FSTRONG%3EIs%20there%20an%20alternative%20to%20what%20I'm%20trying%20to%20do%3F%20Thanks%20in%20advance%20%3A)%3C%2Fimg%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPS%3A%20The%26nbsp%3Bsub-query%20in%20the%20toscalar()%20is%20actually%20the%20output%20of%20a%20very%20huge%20table%3B%20used%20range%20only%20for%20demonstration%20purpose.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-213136%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-213142%22%20slang%3D%22en-US%22%3ERe%3A%20Accessing%20a%20column%20from%20within%20toscalar()%20-%20Log%20Analytics%20Query%20Language%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-213142%22%20slang%3D%22en-US%22%3EI%20am%20trying%20to%20run%20the%20sub-query%20for%20each%20value%20of%20the%20range%201%20to%2030%2C%20and%20the%20sub-query%20results%20in%20a%20single%20cell%20table.%20The%20sub-query%20needs%20to%20have%20access%20to%20the%20current%20value%20from%20the%20range%2C%20but%20it%20isn't%20being%20recognized%20inside%20toscalar()%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-213139%22%20slang%3D%22en-US%22%3ERe%3A%20Accessing%20a%20column%20from%20within%20toscalar()%20-%20Log%20Analytics%20Query%20Language%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-213139%22%20slang%3D%22en-US%22%3E%3CP%3Enot%20sure%20what%20you%20are%20trying%20to%20do%2C%20exactly.%3C%2FP%3E%0A%3CP%3Ein%20the%20given%20example%2C%20the%20input%20to%20the%20where%20clause%20is%3A%20%22%3CSPAN%3Erange%20index%20from%201%20to%2030%20step%201%22%2C%20so%20the%20where%20clause%20can%20only%20recognize%20one%20column%2C%20named%20%22index%22.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3ECan%20you%20explain%20a%20bit%20more%20what%20you%20want%20to%20do%3F%20is%20the%20repeating%20of%20subquery%20related%20to%20the%20index%20of%20each%20row%3F%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Aarohi Chowdary
New Contributor

Speaking in terms of C, I need to do something like this:

for(i = 0; i < 30; i++)

     subquery(i);      

The subquery returns a table with a single cell. I am trying to do something like this:

range offset from 1 to 30 step 1
| project Column = toscalar( range index from 1 to 30 step 1 | where index == offset)

But the offset in the toscalar() is not being recognized; I'm getting the following error: 'where' operator: Failed to resolve column or scalar expression named 'offset'. Is there an alternative to what I'm trying to do? Thanks in advance :)

 

PS: The sub-query in the toscalar() is actually the output of a very huge table; used range only for demonstration purpose.

 

2 Replies

not sure what you are trying to do, exactly.

in the given example, the input to the where clause is: "range index from 1 to 30 step 1", so the where clause can only recognize one column, named "index".

Can you explain a bit more what you want to do? is the repeating of subquery related to the index of each row? 

I am trying to run the sub-query for each value of the range 1 to 30, and the sub-query results in a single cell table. The sub-query needs to have access to the current value from the range, but it isn't being recognized inside toscalar()
Related Conversations