简体   繁体   English

如何以小时为单位计算两个日期时间列之间的时间差,不包括周末和 power bi 中的营业时间?

[英]how to calculate time difference between two datetime columns in hours excluding weekends and business hours in power bi?

Hi wondering how to calculate time difference between two datetime columns (ENDDATETIME - STARTDATETIME) in hours (accounting mins and secs also) excluding weekends (Sat and Sun) and non-business hours ( between 5 pm to 8 am) in power bi?您好想知道如何计算两个日期时间列(ENDDATETIME - STARTDATETIME)之间的时间差(包括分钟和秒),不包括周末(周六和周日)和非工作时间(下午 5 点到上午 8 点之间)在 power bi 中? Thanks谢谢

ID ID STARTDATETIME开始日期时间 ENDDATETIME结束日期时间
102 102 2019-11-24 13:46:48.000 2019-11-24 13:46:48.000 2019-12-16 04:51:11.000 2019-12-16 04:51:11.000
105 105 2019-10-17 12:18:18.000 2019-10-17 12:18:18.000 2019-10-31 04:50:57.000 2019-10-31 04:50:57.000
108 108 2019-11-30 10:56:37.000 2019-11-30 10:56:37.000 2019-12-04 04:51:19.000 2019-12-04 04:51:19.000
110 110 2019-10-25 17:31:29.000 2019-10-25 17:31:29.000 2019-11-20 04:51:11.000 2019-11-20 04:51:11.000
112 112 2019-11-25 16:03:02.000 2019-11-25 16:03:02.000 2019-11-25 17:51:04.000 2019-11-25 17:51:04.000
115 115 2019-11-04 14:12:09.000 2019-11-04 14:12:09.000 2019-11-07 09:00:02.000 2019-11-07 09:00:02.000

Rather then posting the Power Query code here, I would prefer you download the sample power BI file from Here and check the steps for achieving the desired output.与其在此处发布Power Query代码,我更希望您从此处下载示例 Power BI 文件并检查实现所需 output 的步骤。

Some steps might have possibilities to combine, but I keep them separate so that you can visualize the changes in each step easily.有些步骤可能有合并的可能,但我将它们分开,以便您可以轻松地可视化每个步骤中的变化。

This same can be achieved using DAX but I guess the code will be more complex.使用 DAX 也可以实现这一点,但我猜代码会更复杂。 Please let me know if you face any issue.如果您遇到任何问题,请告诉我。

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

相关问题 Power BI 计算不包括周末和非工作时间的时差 - Power BI calculating time difference excluding weekends and non working hours Power BI - 以小时(> 24 小时)计算两个日期/时间值之间的差异,然后计算平均值 - Power BI - Calculate difference between two date/time values in Hours (> 24 hours) and then Average Power BI 计算多级矩阵中两列之间的差异 - Power BI calculate the difference between two columns in a multi level matrix 根据进出时间员工出勤率计算“工作时间” - Calculate “Working hours ” based on IN and OUT time Employee Attendance Power bi 使用日期之间的差异为BI供电并分配时间 - Power BI using difference between dates and allocating them hours 我目前正在尝试计算销售表中两个日期之间的差异,不包括 Power BI 中的周末 - I'm currently trying to calculate the difference between two dates in sales table excluding weekend in power BI 如何计算 Power BI 中表格视觉对象的两列之间的差异? - How can I calculate the difference between two columns of a table visual in Power BI? 计算 Power BI 中两行之间的差异 - Calculate difference between two rows in Power BI 计算日期和时间的差异时,不包括Power Bi中的周末 - Excluding Weekends in Power Bi when calculating the difference in dates and times POWER BI日期差异(不包括周末) - POWER BI datesdifference excluding weekends
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM