日期范围之间的 Power BI 累计计数

Power BI cumulative count between date range

我正在尝试制作一个公告板,告诉我每个月过去 3 个月的活跃用户,我有一个日历 table,其中包含 2020 年每个月的最后一天,我的想法是当我点击 03/31/2020 时,我将显示过去 3 个月登录的特定用户数的数据。

每个柱状图都必须存在

January (count from 11/01/2019 to 01/31/2020)
February (count from 12/01/2019 to 02/29/2019)
March (count from 01/01/2020 to 03/31/2020)

如果我点击 04/30/2020

January (count from 11/01/2019 to 01/31/2020)
February (count from 11/01/2019 to 01/31/2020)
March (count from 12/01/2019 to 02/29/2019)
April (count from 02/01/2020 to 04/30/2020)

如何使用 DAX 中的度量来执行此操作?

我附上一张图片,其中包含我想做的事情的示例。

创建一个使用 DatesInPeriod() 的度量,如下所示:

3 Month Distict Count = 
        CALCULATE(
            DISTINCTCOUNT(YourTableName[CountColumn]),
                DATESINPERIOD('Calendar'[Date]),
                    LASTDATE('Calendar'[Date]),
                        -3,
                            MONTH))

我的问题已通过以下 dax 代码解决:

Login Count = CALCULATE(DISTINCTCOUNT(user_logins[key]), FILTER(ALLEXCEPT(user_logins,user_logins[chanel]), user_logins[login_date]>=date(YEAR(MIN(calendar[Date])), month(MIN(calendar[Date]))-2,1) && user_logins[login_date]<date(YEAR(MIN(calendar[Date])), month(MIN(calendar[Date]))+1,1)))

感谢先生的帮助。巴拉吉