简体   繁体   English

kusto 查询 - 我想在图表上排除第 2 个和第 4 个星期六以及星期日

[英]kusto query - i want exclude 2nd and 4th Saturday along with Sunday on chart

i want exclude 2nd and 4th Saturday along with Sunday on chart.我想在图表上排除第 2 个和第 4 个星期六以及星期日。

i am trying this code but its not working it gives an error -我正在尝试这段代码,但它不起作用,它给出了一个错误 -

Relop semantic error: SEM0025: One of the values provided to the 'in' operator does not match the left side expression type 'timespan', consider using explicit cast Relop 语义错误:SEM0025:提供给“in”运算符的值之一与左侧表达式类型“timespan”不匹配,请考虑使用显式强制转换

| extend Eventdate = strcat(datetime_part("day",timestamp))
| extend day = dayofweek(timestamp)
| extend day_strg = tostring(Eventdate)
| 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 = case(Week_Num in (2, 4) and day in (5, 6), "weekend","working day") 
| project Eventdate, timestamp, day, day_strg, Week_Num, weekend

Here is an example of what it seems that you are asking for:这是您似乎要求的示例:

range timestamp from datetime(2022-02-01 08:06:45.7316316) to datetime(2022-03-01 08:06:45.7316316) step 1d
| extend DayOfMonth = dayofmonth(timestamp)
| extend Day = startofday(timestamp)
| extend Week_Num = case(
   DayOfMonth <=7, 1,
   DayOfMonth <=14, 2,
   DayOfMonth <=21, 3,
   DayOfMonth <=28, 4,
   5)
| extend weekend = iif((Week_Num in (2, 4) and (dayofweek(timestamp)/1d) == 6) or dayofweek(timestamp)/1d == 0, "weekend","working day") 
| project timestamp, Day, Week_Num, weekend
timestamp时间戳 Day Week_Num周数 weekend周末
2022-02-01 08:06:45.7316316 2022-02-01 08:06:45.7316316 2022-02-01 00:00:00.0000000 2022-02-01 00:00:00.0000000 1 1个 working day工作日
2022-02-02 08:06:45.7316316 2022-02-02 08:06:45.7316316 2022-02-02 00:00:00.0000000 2022-02-02 00:00:00.0000000 1 1个 working day工作日
2022-02-03 08:06:45.7316316 2022-02-03 08:06:45.7316316 2022-02-03 00:00:00.0000000 2022-02-03 00:00:00.0000000 1 1个 working day工作日
2022-02-04 08:06:45.7316316 2022-02-04 08:06:45.7316316 2022-02-04 00:00:00.0000000 2022-02-04 00:00:00.0000000 1 1个 working day工作日
2022-02-05 08:06:45.7316316 2022-02-05 08:06:45.7316316 2022-02-05 00:00:00.0000000 2022-02-05 00:00:00.0000000 1 1个 working day工作日
2022-02-06 08:06:45.7316316 2022-02-06 08:06:45.7316316 2022-02-06 00:00:00.0000000 2022-02-06 00:00:00.0000000 1 1个 weekend周末
2022-02-07 08:06:45.7316316 2022-02-07 08:06:45.7316316 2022-02-07 00:00:00.0000000 2022-02-07 00:00:00.0000000 1 1个 working day工作日
2022-02-08 08:06:45.7316316 2022-02-08 08:06:45.7316316 2022-02-08 00:00:00.0000000 2022-02-08 00:00:00.0000000 2 2个 working day工作日
2022-02-09 08:06:45.7316316 2022-02-09 08:06:45.7316316 2022-02-09 00:00:00.0000000 2022-02-09 00:00:00.0000000 2 2个 working day工作日
2022-02-10 08:06:45.7316316 2022-02-10 08:06:45.7316316 2022-02-10 00:00:00.0000000 2022-02-10 00:00:00.0000000 2 2个 working day工作日
2022-02-11 08:06:45.7316316 2022-02-11 08:06:45.7316316 2022-02-11 00:00:00.0000000 2022-02-11 00:00:00.0000000 2 2个 working day工作日
2022-02-12 08:06:45.7316316 2022-02-12 08:06:45.7316316 2022-02-12 00:00:00.0000000 2022-02-12 00:00:00.0000000 2 2个 weekend周末
2022-02-13 08:06:45.7316316 2022-02-13 08:06:45.7316316 2022-02-13 00:00:00.0000000 2022-02-13 00:00:00.0000000 2 2个 weekend周末
2022-02-14 08:06:45.7316316 2022-02-14 08:06:45.7316316 2022-02-14 00:00:00.0000000 2022-02-14 00:00:00.0000000 2 2个 working day工作日
2022-02-15 08:06:45.7316316 2022-02-15 08:06:45.7316316 2022-02-15 00:00:00.0000000 2022-02-15 00:00:00.0000000 3 3个 working day工作日
2022-02-16 08:06:45.7316316 2022-02-16 08:06:45.7316316 2022-02-16 00:00:00.0000000 2022-02-16 00:00:00.0000000 3 3个 working day工作日
2022-02-17 08:06:45.7316316 2022-02-17 08:06:45.7316316 2022-02-17 00:00:00.0000000 2022-02-17 00:00:00.0000000 3 3个 working day工作日
2022-02-18 08:06:45.7316316 2022-02-18 08:06:45.7316316 2022-02-18 00:00:00.0000000 2022-02-18 00:00:00.0000000 3 3个 working day工作日
2022-02-19 08:06:45.7316316 2022-02-19 08:06:45.7316316 2022-02-19 00:00:00.0000000 2022-02-19 00:00:00.0000000 3 3个 working day工作日
2022-02-20 08:06:45.7316316 2022-02-20 08:06:45.7316316 2022-02-20 00:00:00.0000000 2022-02-20 00:00:00.0000000 3 3个 weekend周末
2022-02-21 08:06:45.7316316 2022-02-21 08:06:45.7316316 2022-02-21 00:00:00.0000000 2022-02-21 00:00:00.0000000 3 3个 working day工作日
2022-02-22 08:06:45.7316316 2022-02-22 08:06:45.7316316 2022-02-22 00:00:00.0000000 2022-02-22 00:00:00.0000000 4 4个 working day工作日
2022-02-23 08:06:45.7316316 2022-02-23 08:06:45.7316316 2022-02-23 00:00:00.0000000 2022-02-23 00:00:00.0000000 4 4个 working day工作日
2022-02-24 08:06:45.7316316 2022-02-24 08:06:45.7316316 2022-02-24 00:00:00.0000000 2022-02-24 00:00:00.0000000 4 4个 working day工作日
2022-02-25 08:06:45.7316316 2022-02-25 08:06:45.7316316 2022-02-25 00:00:00.0000000 2022-02-25 00:00:00.0000000 4 4个 working day工作日
2022-02-26 08:06:45.7316316 2022-02-26 08:06:45.7316316 2022-02-26 00:00:00.0000000 2022-02-26 00:00:00.0000000 4 4个 weekend周末
2022-02-27 08:06:45.7316316 2022-02-27 08:06:45.7316316 2022-02-27 00:00:00.0000000 2022-02-27 00:00:00.0000000 4 4个 weekend周末
2022-02-28 08:06:45.7316316 2022-02-28 08:06:45.7316316 2022-02-28 00:00:00.0000000 2022-02-28 00:00:00.0000000 4 4个 working day工作日
2022-03-01 08:06:45.7316316 2022-03-01 08:06:45.7316316 2022-03-01 00:00:00.0000000 2022-03-01 00:00:00.0000000 1 1个 working day工作日

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我只想在图表上显示工作日期(例如,我想从聊天中排除第 2、4 个星期六和所有星期日日期。) - i want to show only working dates on chart (e.g i want exclude 2nd, 4th suturday and all sunday dates from chat.) 如何在 Kusto 查询中排除周末? - How to exclude weekends in Kusto query? BigQuery 获取周末周六至周日的数据 - BigQuery fetching data for weekends Saturday to Sunday 如何部署 Google Cloud Function(第 2 代)? - How do I deploy a Google Cloud Function (2nd generation)? Kusto - 从 Kusto 图表中的变量(图例)中删除附加文本 - Kusto - Remove additional text from variable (Legend) in Kusto chart Kusto 查询管道查询 - Kusto Query Pipeline Query 我需要一个查询来比较一个星期六的总销售额与一年中其余时间的平均星期六总销售额 - I need a query to compare one Saturday's total sales with the rest of the year's average Saturday's total sales 使用 Kusto 查询返回的字典 - Use Dictionary returned by Kusto Query 条件筛选器的 Kusto 查询帮助 - Kusto query help for Condition filter 如何更好地优化此 Kusto 查询以获取我的日志 - How better I can optimize this Kusto Query to get my logs
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM