Power BI度量总计(HASONEFILTER)

时间:2019-05-30 14:27:02

标签: powerbi

我有一个Power BI报告,该报告可计算一个月内到期的作业数量,并报告按时完成多少作业。该报告运行良好,只是度量总计未正确汇总,如表列所示。

我已采取以下措施:

Done on time = Jobs completed in their due month 
Outside time = Jobs completed after when they were due.
Incomplete = Used to identify incomplete jobs
% Perf = Percentage of jobs completed on time."

其他字段:

DUE = Due Date

completed = job completion date


I have found a possible answer to this using (HASONEFILTER) but cannot get it to work.

措施

Done on time = 
    VAR DueMonth = MONTH ( FIRSTDATE ( Table1[due_date] ) )
RETURN
    CALCULATE ( 
        [Due],
        FILTER ( Table1,
        MONTH ( Table1[completed] ) = DueMonth || MONTH ( 
Table1[completed] ) = DueMonth -1 || MONTH ( Table1[completed] ) = DueMonth +1 
    )
)


Outside time = 
VAR DueMonth = MONTH ( FIRSTDATE ( Table1[due_date] ) )
RETURN
    CALCULATE ( 
        [Due] - [Done on time],
        FILTER ( 
            Table1,
            MONTH ( Table1[completed] ) <> DueMonth || MONTH ( Table1[completed] ) = DueMonth -1 || MONTH ( Table1[completed] ) = DueMonth +1 || 
        NOT ISBLANK ( Table1[completed] )
    )
)



% Perf = 
    DIVIDE ( 
        [Done on time],
        [Due],
        BLANK()
    ) * 100   

结果将正确地合计列度量,现有输出下方的屏幕截图。 Sample existing output

0 个答案:

没有答案