添加以下措施:
措施“到期”:
Due = COUNTROWS ( Table1 )
衡量“按时完成”:
Done on time =
VAR DueMonth = MONTH ( FIRSTDATE ( Table1[due_date] ) )
RETURN
CALCULATE (
[Due],
FILTER (
Table1,
MONTH ( Table1[completed] ) = DueMonth
)
)
测量“外部时间”:
Outside time =
VAR DueMonth = MONTH ( FIRSTDATE ( Table1[due_date] ) )
RETURN
CALCULATE (
[Due],
FILTER (
Table1,
MONTH ( Table1[completed] ) <> DueMonth &&
NOT ISBLANK ( Table1[completed] )
)
)
测量“不完整”:
Incomplete =
VAR DueMonth = MONTH ( FIRSTDATE ( Table1[due_date] ) )
RETURN
CALCULATE (
[Due],
FILTER (
Table1,
ISBLANK ( Table1[completed] )
)
)
测量“百分比性能”
% Perf =
DIVIDE (
[Done on time],
[Due],
BLANK()
)
due_date.month
在报告中分组。
有关工作示例 PBIX 文件,请参阅https://pwrbi.com/so_55513978/ 。
在评论中更新问题后编辑:
如果你真的必须的话,有很多方法可以创建一个将这些度量与按完成日期计算的每月计数相结合的可视化。这是一种方法:
创建一个“报告列”表:
Report Columns =
VAR ListMeasures =
DATATABLE (
"Header", STRING,
"Sort Order", INTEGER,
"First Of Month", DATETIME,
{
{"Due in month", 1, BLANK() },
{"Done on time", 2, BLANK() },
{"Outside time", 3, BLANK() },
{"Incomplete", 4, BLANK() },
{"% Perf", 5, BLANK() }
}
)
VAR ListMonths =
CALCULATETABLE(
GROUPBY (
ADDCOLUMNS (
DISTINCT ( Table1[completed] ),
"Header", FORMAT ( Table1[completed], "YYYY-MMM" ),
"Sort Order", YEAR ( Table1[completed] ) * 100 + MONTH ( Table1[completed] ),
"First Of Month", DATE ( YEAR ( Table1[completed] ), MONTH ( Table1[completed] ), 1 )
),
[Header], [Sort Order], [First Of Month]
),
Table1[completed] <> BLANK()
)
RETURN
UNION (
ListMeasures,
ListMonths
)
将列设置Header
为按列排序Sort Order
创建度量“报告度量”:
Report Measure =
IF (
NOT HASONEFILTER ( 'Report Columns'[Header] ),
BLANK(),
SWITCH (
VALUES ( 'Report Columns'[Header] ),
"Due in month", [Due],
"Done on time", [Done on time],
"Outside time", [Outside time],
"Incomplete", [Incomplete],
"% Perf", [% Perf],
CALCULATE (
[Due],
FILTER (
Table1,
DATE ( YEAR ( Table1[completed] ), MONTH ( Table1[completed] ), 1 ) = VALUES ( 'Report Columns'[First Of Month] )
)
)
)
)
添加矩阵可视化,包含Table1[due_date]
行、Report Columns[Header]
列和[Report Measure]
值。适合的格式。
更新的示例 PBIX 文件:https ://pwrbi.com/so_55513978-2/