Finding cummulative sum of MAX values

允我心安 提交于 2019-11-28 14:32:20

This is a bit similar to this question and this question and this question as far as subtotaling, but also includes a cumulative component as well.

You can do this in two steps. First, calculate a table that gives the max for each year and then use a cumulative total pattern.

CumSum = 
VAR Summary =
    SUMMARIZE(
        ALLSELECTED(Table1),
        Table1[Year],
        "Max",
        MAX(Table1[MonthlyValue])
    )
RETURN
    SUMX(
        FILTER(
            Summary, 
            Table1[Year] <= MAX(Table1[Year])
        ),
        [Max]
    )

Here's the output:

If you expand to the month level, then it looks like this:


Note that if you only need the subtotal to work leaving each row as a max (15, 22, 17, 54) rather than as a cumulative sum of maxes (15, 37, 54, 54), then you can use a simpler approach:

MaxSum =
    SUMX(
        VALUES( Table1[Year] ),
        CALCULATE( MAX( Table1[MonthlyValue] ) )
    )

This calculates the max for each year separately and then adds them together.


External References:

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!