Search code examples
azureazure-application-insightskusto-explorer

i want to show only working dates on chart (e.g i want exclude 2nd, 4th suturday and all sunday dates from chat.)


i have a data which i need to project it on chart...i have created a table where i have specified the all weekend now i want only to project working days dates on chart and dont want see weekend on chart.

| where name has "samplelog"
| extend Eventdate = strcat(datetime_part("day",timestamp))
| extend day_strg = tostring(Eventdate)
| extend day_num = dayofweek(timestamp) / 1d
| extend Week_Num = case(day_strg in (range(1, 7, 1)), "1", day_strg in (range(8, 14, 1)), "2",day_strg in (range(15, 21, 1)), "3",day_strg in (range(22, 31, 1)), "4", "0")
| extend weekend = iff(Week_Num in (2,4) and day_num == 6 or day_num == 0, "weekend", "working day")```


Solution

  • For filtering some specific values you have to use the Where condition

    Follow the workaround

    In your code, I have added the Where condition to filter

     |where weekend != "weekend"
    

    Changes added in your query

    range timestamp from datetime(2022-03-01) to datetime(2022-04-01) step 1d
    | extend Eventdate = strcat(datetime_part("day",timestamp))
    | extend day_strg = tostring(Eventdate)
    | extend day_num = dayofweek(timestamp) / 1d
    | extend Week_Num = case(day_strg in (range(1, 7, 1)), "1", day_strg in (range(8, 14, 1)), "2",day_strg in (range(15, 21, 1)), "3",day_strg in (range(22, 31, 1)), "4", "0")
    | extend weekend = iff(Week_Num in (2,4) and day_num == 6 or day_num == 0, "weekend", "working day")
    |where weekend != "weekend"
    
    

    Results

    I can see only the working days result enter image description here

    enter image description here