PowerBI - 将每日数据汇总为每月计数的措施

PowerBI - Measure to Summarize Daily data into Monthly Counts

我有一个 table 的缺陷数据,我想创建一个 MEASURE 来计算每个月的缺陷数。我知道我需要使用日期 table,但到目前为止我的尝试还没有成功。

我正在寻找的是按月简单计数:

1 月 125 日 2月225日 220 年 3 月 4 月 120 日

缺陷Table

日期Table

这是我在没有任何运气的情况下尝试构建的 Measure...

Monthly Defects = 

// TOTALYTD(COUNT(Defects[Defect]), 'Date'[Date])

VAR defectDate = FIRSTDATE(Defects[Created Date]) 
VAR defectYear = YEAR(defectDate)
VAR defectMonth = MONTH(defectDate)

RETURN
    CALCULATE (
        COUNT(Defects[Defect]),
        FILTER (
            Defects,
                Defects[Created Date] <= defectDate &&
                (YEAR (Defects[Created Date]) = defectYear) && (MONTH(Defects[Created Date]) = defectMonth)
        )
    )

这就是我最终想要做的事情。

如果您只想每月计数,那么您的衡量标准应该是

Monthly Defects=COUNTROWS(Defects)

这是假设您的缺陷 table 和约会对象 table 之间存在关系。