0

我正在尝试创建一个矩阵表,该表将计算一个月内到期的工作数量以及它们是否按时完成。

目前我可以做到这一点。 在此处输入图像描述

我尝试过总结数据、制定措施等。但无济于事。

我需要制作以下内容:

期望的输出

我的数据源是一系列交易行,其中包括

1) 交易到期日 2) 交易完成日期

术语定义:

Due in month        Count of due date
Done on time        Completed within due month
Outside time        completed outside due month
"%Perf"             percentage completed on time.

对此的任何帮助将不胜感激。

在此处输入图像描述

4

1 回答 1

1

添加以下措施:

措施“到期”:

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/

于 2019-04-05T11:14:50.250 回答