Forum Discussion

JankoC's avatar
JankoC
Regular Visitor
4 years ago
Solved

How do I subtract sum from each previous date in table?

What I have so far:

Desired Result = 
(
    var test =
        CALCULATE(SUM('Datum tabela'[Vsota sporočil]), FILTER('Datum tabela', 'Datum tabela'[Datum]=MAX('Datum tabela'[Datum])))
         -
        CALCULATE(SUM('Datum tabela'[Vsota sporočil]), FILTER('Datum tabela', 'Datum tabela'[Datum]=MAX('Datum tabela'[Datum])-1))

    return test
)

What I'd like to achieve (image blow) - instead of current "Desired Result" values I'd like the values to be subtracted from the previous date. For "Zdravstveni dom" rows "Dom A" instead of the progression being 260 -> 262 -> 263, I'd like it to be 260 -> 2 -> 1 (growth from each previous date). Any ideas?