none
How can I sort a KQL query like this one RRS feed

  • Question

  • Hi friends,

    I have a query like the following one. I need to show timestamp in the format "dd-MM-yy". But I can't sort with that format. Please have a look over the following KQL query and suggest me the solution.

    requests

    | extend dateOnly = format_datetime(timestamp, "dd-MM-yy")
    | summarize totalCount=sum(itemCount) by dateOnly
    | sort by datetime(dateOnly) // This thing is causing wrror
    | render timechart

    Thursday, October 3, 2019 5:44 AM

All replies

  • Hello, AseemS!

    I think this is what you are after:

    requests
    | extend dateOnly = format_datetime(timestamp, "dd-MM-yy")
    | summarize totalCount=sum(itemCount) by dateOnly
    | sort by dateOnly asc 
    | render timechart

    Thursday, October 3, 2019 9:36 PM
    Moderator
  • Thanks mate for replying. I did so but it does not sort properly with dateOnly.

    Friday, October 4, 2019 10:09 AM
  • I tried the query again and got what I was expecting from our demo environment, which you can use to test KQL.  That query should give you exactly what you see below.  Would you mind posting what your graph looks like after using that query?

    This is the demo environment result:

    Wednesday, October 9, 2019 2:33 AM
    Moderator