Semantic error: Unresolved reference binding: 'idx'

Anvesh Kasani 1 Reputation point Microsoft Employee
2023-01-13T09:40:26.6866667+00:00

Hi Team, When I am running the below query, it failed with the error "Semantic error: Unresolved reference binding: 'idx'", Please can anyone help with this?

let wau = (cDate:datetime) { 
toscalar(customEvents
| where timestamp > cDate - 7d and timestamp < cDate
| summarize dcount(user_Id))
};
range idx from datetime(2022-12-01) to now() step 1d 
| extend wau(idx)

If I use now() as a parameter, the query is running fine.

| extend wau(now())
Azure Data Explorer
Azure Data Explorer
An Azure data analytics service for real-time analysis on large volumes of data streaming from sources including applications, websites, and internet of things devices.
480 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. ShaikMaheer-MSFT 37,896 Reputation points Microsoft Employee
    2023-01-16T10:17:14.2666667+00:00

    Hi Anvesh Kasani,

    Thank you for posting query in Microsoft Q&A Platform.

    You are hitting this failure because of limitations of toscalar()function. toscalar()function cannot be applied on a scenario where function applies on each row. click here to know more about it.

    For example, below code results in same error which you are facing.

    let _dataset2 = datatable(x:long, y:long) [ 1, 2, 3, 4, 5, 6];
    let tg = (x_: long)
    {
        toscalar(_dataset2| where x == x_ | project y);
    };
    _dataset1
    | extend y = tg(x)
    

    To avoid error where we can use join operator as below.

    let _dataset1 = datatable(x: long)[1, 2, 3, 4, 5];
    let _dataset2 = datatable(x: long, y: long) [1, 2, 3, 4, 5, 6];
    _dataset1
    | join (_dataset2) on x 
    | project x, y
    

    Hope this helps.


    Please consider hitting Accept Answer button. Accepted answers help community as well.

    0 comments No comments