简体   繁体   中英

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")```

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在此处输入图像描述

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM