如何计算 power bi 中的总和和最大使用屏幕数?

how to calculate total sum and maximum used screen count in power bi?

如何计算启用日期的总计数和最大使用屏幕数及其名称

我的输入table

Date        Name        Id  Count   Screen  Enabled Date
03-01-2020  Karthikeyan 1   4       Login   03-01-2020
03-01-2020  Karthikeyan 1   3       Logout  03-01-2020
05-01-2020  Karthikeyan 1   6       Logout  03-01-2020
05-01-2020  Sumit       2   9       Login   05-01-2020
05-01-2020  Sumit       2   5       Logout  05-01-2020

我的密码是

enabledDateSummary = 
ADDCOLUMNS(
    ADDCOLUMNS(
            SUMMARIZE(
                enabledDate,
                enabledDate[Id],
                enabledDate[Name],enabledDate[Enabled Date]
            ),
        "TotalCount", CALCULATE( SUM( enabledDate[Count] ), FILTER(enabledDate, 
        enabledDate[Date] = MIN(enabledDate[Enabled Date])),
        ALLEXCEPT(enabledDate, enabledDate[Enabled Date], enabledDate[Name])), 
        "ScreenCount", CALCULATE( MAX( enabledDate[Count] ), 
        ALLEXCEPT(enabledDate,enabledDate[id]) )
    ),
    "Screen",
    VAR CurrentCount = [ScreenCount]
    RETURN CALCULATE( MIN(enabledDate[Screen]), enabledDate[Count] = CurrentCount )
)

输出是

预期输出table

我已经通过使用 SUMX() 函数而不是 SUM()

函数解决了这个问题

enabledDateSummary

enabledDateSummary = 
ADDCOLUMNS(
    ADDCOLUMNS(
    FILTER(
            SUMMARIZE(
                enabledDate,
                enabledDate[Id],
                enabledDate[Name], enabledDate[Enabled Date]
            ),enabledDate[Enabled Date] <> DATE(1970,01,01)
        ),
        "TotalCount", CALCULATE(SUMX(FILTER(enabledDate, 
        enabledDate[Date] = enabledDate[Enabled Date]),[Count])), 
        "ScreenCount", CALCULATE( MAX( enabledDate[Count] ) )
    ),
    "Screen",
    VAR CurrentCount = [ScreenCount]
    RETURN CALCULATE( MIN(enabledDate[Screen]), enabledDate[Count] = CurrentCount )
)

enabledDateSummary 输出: