Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powerbi 总计数之和(基于用户计数运行总计)-是否可能?_Powerbi_Dax - Fatal编程技术网

Powerbi 总计数之和(基于用户计数运行总计)-是否可能?

Powerbi 总计数之和(基于用户计数运行总计)-是否可能?,powerbi,dax,Powerbi,Dax,我正在尝试对首次访问该网页的用户进行累计计数 这张桌子看起来像 UserID , Initial Access Date 100, 2019-05-10 200, 2019-05-20 100, 2019-05-21 100, 2019-05-25 200, 2019-05-30 300, 2019-06-01 当前表达式: Cumulative Total = CALCULATE ( DISTINCTCOUNT ( [USE

我正在尝试对首次访问该网页的用户进行累计计数

这张桌子看起来像

UserID , Initial Access Date

    100, 2019-05-10 
    200, 2019-05-20 
    100, 2019-05-21 
    100, 2019-05-25 
    200, 2019-05-30 
    300, 2019-06-01
当前表达式:

Cumulative Total =
CALCULATE (
    DISTINCTCOUNT ( [USERID] ),
    FILTER (
        ALLSELECTED ( TABLE ),
        [INITIAL ACCESS DATE] <= MAX ( [INITIAL ACCESS DATE] )
    )
)
累计总数=
算计(
DISTINCTCOUNT([USERID]),
滤器(
全部选定(表),

[初始访问日期]1-在Power Bi中上载事实表

2-创建日期表

Date = CALENDARAUTO()
然后

3-集关系

4-您可以计算一组两个度量值:

首先

InitialAccess = 
VAR InitialAccessInCurrentPeriod = 
DISTINCTCOUNT(Fact_T[UserID ])
RETURN
InitialAccessInCurrentPeriod
然后:

InitialAccessCumulated = 
VAR MaxDateInPeriod = MAX('Date'[Date])                      // Retrieve the last date in current filter context
VAR StartingDate = MINX(ALLSELECTED('Date');[Year])          // Retrieve the lowest year selected on slicer
RETURN
CALCULATE(
    [InitialAccess];                                        // Compute the number of initial access
    FILTER(                                                 // In a nex filter context where all the dates
        ALL('Date');                                        // Equal or superior to the lowest date selected
        'Date'[Year]>=StartingDate
        &&
        'Date'[Date]<= MaxDateInPeriod                       // Until the last date visible in the current row context
    )
)

最后,我在不创建额外的列或度量值的情况下使其工作

Cumulative Total =

CALCULATE (
    SUMX (
        Table,
        IF ( DISTINCTCOUNT ( Table[UserID] ) > 0, 1, 0 )
    ),
    FILTER (
        ALLSELECTED ( Table ),
        Table[InitialAccessDate]
            <= MAX ( Table[InitialAccessDate] )
    )
)
累计总数=
算计(
萨姆克斯(
桌子
IF(DISTINCTCOUNT(表[UserID])>0,1,0)
),
滤器(
全部选定(表),
表[初始访问日期]
我喜欢你详述(评论)它的方式。:)
UserID   Initial Access Date
50  12/12/2018
100 10/05/2019
200 20/05/2019
100 21/05/2019
100 25/05/2019
200 30/05/2019
300 01/06/2019
400 04/02/2020
Cumulative Total =

CALCULATE (
    SUMX (
        Table,
        IF ( DISTINCTCOUNT ( Table[UserID] ) > 0, 1, 0 )
    ),
    FILTER (
        ALLSELECTED ( Table ),
        Table[InitialAccessDate]
            <= MAX ( Table[InitialAccessDate] )
    )
)