【问题标题】:Power BI Avg weighted time format measuresPower BI Avg 加权时间格式度量
【发布时间】:2021-09-08 08:08:56
【问题描述】:

我创建了两个度量来计算我的加权 ACW 平均值,但时间格式显示不正确,我被卡住了。我有一个从 Postgres 导入 Powerbi 的表,我用于我的 acw 时间的列在 Inboundlog 表中以秒为单位。

为了获得我的平均值,我首先创建了一个衡量 ACW 总时间的度量。

SUM ACW = SUM(inboundlog[time_acwork])

然后我创建了第二个度量来将此结果除以我处理的呼叫总数

 AVG ACW = DIVIDE([SUM ACW], [Calls Handled])

添加到我的表格时,它会显示正确的结果,但不是时间格式。当我将格式添加到“HH:MM:SS”或“MM:SS”的AVG ACW测量时,它会抛出结果。有没有办法我可以操纵以时间格式显示但结果正确。

这里是正确的结果,不是时间格式。

这是我要绑定的屏幕截图。

inboundlog 表中数据类型的屏幕截图。

Time_acwork

【问题讨论】:

  • 请不要在互联网上大写。这被认为是大喊大叫,不礼貌。
  • 知道inboundlog[time_acwork] 列的数据类型会很有用 - 这是日期/时间值还是十进制?请在您的屏幕截图中显示该数据,以便我们了解您正在处理的内容。编辑你的问题来做到这一点。不要在评论中发布。您可以在更新问题后发表评论,这样会通知关注此主题的人。
  • 谢谢我刚刚发布了数据类型的截图。

标签: time powerbi format measure weighted


【解决方案1】:

使用此处的代码: https://community.powerbi.com/t5/Community-Blog/Aggregating-Duration-Time/ba-p/22486

Duration = 
// Duration formatting 
// * @konstatinos 1/25/2016
// * Given a number of seconds, returns a format of "hh:mm:ss"
//
// We start with a duration in number of seconds
VAR Duration = [Duration in Seconds]
// There are 3,600 seconds in an hour
VAR Hours =
    INT ( Duration / 3600)
// There are 60 seconds in a minute
VAR Minutes =
    INT ( MOD( Duration - ( Hours * 3600 ),3600 ) / 60)
// Remaining seconds are the remainder of the seconds divided by 60 after subtracting out the hours 
VAR Seconds =
    ROUNDUP(MOD ( MOD( Duration - ( Hours * 3600 ),3600 ), 60 ),0) // We round up here to get a whole number
// These intermediate variables ensure that we have leading zero's concatenated onto single digits
// Hours with leading zeros
VAR H =
    IF ( LEN ( Hours ) = 1, 
        CONCATENATE ( "0", Hours ),
        CONCATENATE ( "", Hours )
      )
// Minutes with leading zeros
VAR M =
    IF (
        LEN ( Minutes ) = 1,
        CONCATENATE ( "0", Minutes ),
        CONCATENATE ( "", Minutes )
    )
// Seconds with leading zeros
VAR S =
    IF (
        LEN ( Seconds ) = 1,
        CONCATENATE ( "0", Seconds ),
        CONCATENATE ( "", Seconds )
    )
// Now return hours, minutes and seconds with leading zeros in the proper format "hh:mm:ss"
RETURN
    CONCATENATE (
        H,
        CONCATENATE ( ":", CONCATENATE ( M, CONCATENATE ( ":", S ) ) )
    )

【讨论】:

    猜你喜欢
    • 2022-10-05
    • 2021-12-18
    • 1970-01-01
    • 2023-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-06
    相关资源
    最近更新 更多