计算Power BI中的会话持续时间

时间:2019-09-04 12:43:48

标签: powerbi duration

我有一个包含sessionid和datetime的表。

(A=>2h, B=>3h, C=1h)

我想计算一个会话的持续时间。

通过测量从第一次出现到最后一次出现SessionId的时间来定义会话的持续时间。

我应该如何找到会话的第一次和最后一次发生以及应该如何计算会话的持续时间?

2 个答案:

答案 0 :(得分:1)

在不更改表格的情况下的另一种可能性。创建一个视觉效果,其中SessionID至少是您的组件之一,例如每个会话ID都有行的表格。添加以下措施:

class Ability
  include CanCan::Ability
  def initialize(user)
    return unless user && user.admin?
    can :access, :rails_admin       # only allow admin users to access Rails Admin
    can :read, :dashboard           # allow access to dashboard
    if user.role? :superadmin
      can :manage, :all             # allow superadmins to do anything
    elsif user.role? :manager
      can :manage, [User, Product]  # allow managers to do anything to products and users
    elsif user.role? :sales
      can :update, Product, hidden: false  # allow sales to only update visible products
    end
  end
end

答案 1 :(得分:0)

原始数据

enter image description here

然后我按会话ID分组

enter image description here

然后我将表分组如下

enter image description here

最后,我添加了新列,它给出了分组的最小日期和最大日期之间的日期差异 我们有我们想要的结果。

enter image description here