我只想在图表上显示工作日期(例如,我想从聊天中排除第二个、第四个星期六和所有星期日日期。)

发布于 2025-01-11 03:04:12 字数 551 浏览 1 评论 0原文

我有一个数据,需要将其投影到图表上...我创建了一个表格,其中指定了整个周末,现在我只想在图表上投影工作日日期,不想在图表上看到周末。

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

中性美 2025-01-18 03:04:12

要过滤某些特定值,您必须使用 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"

可以看到仅工作日结果
在此处输入图像描述

在此输入图像描述

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文