【问题标题】:Power BI cumulative count between date range日期范围之间的 Power BI 累积计数
【发布时间】:2020-10-16 03:21:41
【问题描述】:

我正在尝试制作一个板,告诉我过去 3 个月每个月的活跃用户,我有一个日历表,其中包含 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 中的度量来做到这一点?

我附上一张图片,上面有我想做的例子。

【问题讨论】:

    标签: count powerbi dax dashboard date-range


    【解决方案1】:

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

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

    【讨论】:

    • 谢谢,有了您的回答,我可以解决部分问题,但我仍然无法按照我想要的方式可视化数据,但我找到了解决方案。
    【解决方案2】:

    我的问题已通过以下 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)))
    

    感谢先生的帮助。巴拉吉

    【讨论】:

      猜你喜欢
      • 2015-12-19
      • 2021-11-17
      • 1970-01-01
      • 1970-01-01
      • 2022-11-07
      • 1970-01-01
      • 2013-10-03
      • 2012-09-24
      • 1970-01-01
      相关资源
      最近更新 更多