我只想在图表上显示工作日期(例如,我想从聊天中排除第二个、第四个星期六和所有星期日的日期。)
i want to show only working dates on chart (e.g i want exclude 2nd, 4th suturday and all sunday dates from chat.)
我有一个数据,我需要将其投影到图表上...我创建了一个 table,我在其中指定了整个周末,现在我只想将工作日日期投影到图表上,而不想要在图表上查看周末。
| 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")```
要过滤某些特定值,您必须使用 Where 条件
遵循解决方法
在您的代码中,我添加了 Where 条件 以过滤
|where weekend != "weekend"
查询中添加的更改
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"
结果
我只能看到工作日结果
我有一个数据,我需要将其投影到图表上...我创建了一个 table,我在其中指定了整个周末,现在我只想将工作日日期投影到图表上,而不想要在图表上查看周末。
| 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")```
要过滤某些特定值,您必须使用 Where 条件
遵循解决方法
在您的代码中,我添加了 Where 条件 以过滤
|where weekend != "weekend"
查询中添加的更改
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"
结果
我只能看到工作日结果