我对PowerBI很陌生,我正在尝试计算滚动的“按月交付时间”计算列。
每行代表Matrix中的一天
对于我想要获得MonthShippedTotal /(MonthShippedTotal-MonthPastDue)的每一天,这应该是我的滚动时间交付百分比。
这是我到目前为止所得到的结果,但结果却很遥远:
> MonthlyOTD = VAR RowDate = opr_shipments[SHIP_DATE] RETURN
> CALCULATE (
> DIVIDE((COUNT(opr_shipments[CREATE_TIMESTAMP])-COUNTAX(opr_shipments,opr_shipments[PAST_DUE]="1")),COUNT(opr_shipments[CREATE_TIMESTAMP]),0),
> FILTER (
> opr_shipments,
> opr_shipments[SHIP_DATE] <= RowDate
> && MONTH ( opr_shipments[SHIP_DATE] ) = MONTH ( RowDate ) && YEAR ( opr_shipments[SHIP_DATE] ) = YEAR ( RowDate )
> )
> )
MTD货件计算:
MTD Shipments =
VAR RowDate = opr_shipments[SHIP_DATE]
RETURN
CALCULATE (
SUM ( opr_shipments[Daily Shipments] ),
FILTER (
opr_shipments,
opr_shipments[SHIP_DATE] <= RowDate
&& MONTH ( opr_shipments[SHIP_DATE] ) = MONTH ( RowDate ) && YEAR ( opr_shipments[SHIP_DATE] ) = YEAR ( RowDate )
)
)
过期总计算:
PastDueTotal =
VAR RowDate = opr_shipments[SHIP_DATE]
RETURN
CALCULATE (
SUM(opr_shipments[Daily Shipments]),
FILTER (
opr_shipments,
opr_shipments[SHIP_DATE] <= RowDate
&& DAY ( opr_shipments[SHIP_DATE] ) = DAY ( RowDate ) && opr_shipments[PAST_DUE] = "1"
)
)
每个月这个计算都会重新开始。
我想要的输出是:1月1日| 1月28日98% 1月3日98.3%| 95%...... 1月31日 | 2月1日94.5%| 100%
答案 0 :(得分:0)
我认为这样的事情可能适用于MonthlyOTD
计算列。
MonthlyOTD =
VAR RowDate = opr_shipments[SHIP_DATE]
RETURN
SUMX (
FILTER (
opr_shipments,
[SHIP_DATE] <= RowDate
&& MONTH ( [SHIP_DATE] ) = MONTH ( RowDate )
&& YEAR ( opr_shipments[SHIP_DATE] ) = YEAR ( RowDate )
),
DIVIDE ( [MTD Shipments], [MTD Shipments] - [PastDueTotal] )
)
我将这些计算创建为度量而非计算列,注意度量可以在任何上下文中计算,并受到通常需要的过滤器的影响。
更新:OP似乎不需要每月累计总数,因此最终表达式为:
MonthlyOTD = DIVIDE ( ([MTD Shipment Count] - [Lines]), [MTD Shipment Count] )
如果有帮助,请告诉我。