Power BI 平均加权时间格式度量
Power BI Avg weighted time format measures
我已经创建了两个度量来计算我的加权 ACW 平均值,但是时间格式显示不正确,我卡住了。我有一个从 Postgres 导入到 Powerbi 的 table,我用于我的 acw 时间的列在 Inboundlog table.
中以秒为单位
为了得到我的平均值,我首先创建了一个度量来计算总 ACW 时间。
SUM ACW = SUM(inboundlog[time_acwork])
然后我创建了第二个度量,将此结果除以我处理的总呼叫数
AVG ACW = DIVIDE([SUM ACW], [Calls Handled])
当添加到我的 table 时,它显示了正确的结果,但不是时间格式。当我将“HH:MM:SS”或“MM:SS”的格式添加到 AVG ACW 测量时,它会抛出结果。有没有一种方法可以让我以时间格式显示,但结果正确。
这里是正确的结果,不是时间格式。
这是我正在绑定的内容的屏幕截图。
入站日志中数据类型的屏幕截图table。
Time_acwork
使用此处的代码:
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 ) ) )
)
我已经创建了两个度量来计算我的加权 ACW 平均值,但是时间格式显示不正确,我卡住了。我有一个从 Postgres 导入到 Powerbi 的 table,我用于我的 acw 时间的列在 Inboundlog table.
中以秒为单位为了得到我的平均值,我首先创建了一个度量来计算总 ACW 时间。
SUM ACW = SUM(inboundlog[time_acwork])
然后我创建了第二个度量,将此结果除以我处理的总呼叫数
AVG ACW = DIVIDE([SUM ACW], [Calls Handled])
当添加到我的 table 时,它显示了正确的结果,但不是时间格式。当我将“HH:MM:SS”或“MM:SS”的格式添加到 AVG ACW 测量时,它会抛出结果。有没有一种方法可以让我以时间格式显示,但结果正确。
这里是正确的结果,不是时间格式。
这是我正在绑定的内容的屏幕截图。
入站日志中数据类型的屏幕截图table。
Time_acwork
使用此处的代码: 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 ) ) )
)