在PowerQuery中减去两个时间列时得到负值

问题描述 投票:0回答:1

我正在研究 Google 的数据分析顶点案例研究。在给定的数据集中,我需要找到骑行开始时间和结束时间之间的差异。除了几列之外,我总体上得到了正确的值。下面我附上了截图。

I'm cleaning the data using PowerQuery

我减去了 Started_time 和 Ended_time,即 Ended_time - Started_time。由于行程于 23:59:44 开始并于 00:05:50 结束,因此我得到的值是 -23:53:54,该值是负值且不正确。有人可以帮助我如何处理这个值以获得正确的结果吗?

powerbi powerquery data-analysis data-cleaning
1个回答
0
投票

假设此表没有开始/结束日期:

= Table.AddColumn(#"Changed Type", "Duration",
    each if [Started_Time] > [Ended_Time] then #time(24,0,0) - [Started_Time] + [Ended_Time] 
    else [Ended_Time] - [Started_Time], type duration)
© www.soinside.com 2019 - 2024. All rights reserved.