[英]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 ![]() |
STARTDATETIME![]() |
ENDDATETIME![]() |
---|---|---|
102 ![]() |
2019-11-24 13:46:48.000 ![]() |
2019-12-16 04:51:11.000 ![]() |
105 ![]() |
2019-10-17 12:18:18.000 ![]() |
2019-10-31 04:50:57.000 ![]() |
108 ![]() |
2019-11-30 10:56:37.000 ![]() |
2019-12-04 04:51:19.000 ![]() |
110 ![]() |
2019-10-25 17:31:29.000 ![]() |
2019-11-20 04:51:11.000 ![]() |
112 ![]() |
2019-11-25 16:03:02.000 ![]() |
2019-11-25 17:51:04.000 ![]() |
115 ![]() |
2019-11-04 14:12:09.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.