insch
insch

Reputation: 61

Power bi: Calculate the running total and multiply by each months value

I haven't found anything on this, but maybe someone has an idea. I want to calculate the running total of an amount, and then get a measure that allows to show it per month. This then should be multiplied by a value for that month. 

The data I have is looking like this:

base data

Now i want to get as result:

result

So, sum up the amounts and then calculate it with this months value. Is this possible as a measure? Thanks in advance for any help!

Upvotes: 2

Views: 890

Answers (1)

Nick Krasnov
Nick Krasnov

Reputation: 27251

Here is one way to do it:

 //amount_total measure calculates total amount
 amount_total = SUMX(data, data[amount]) 

 //value_total measure calculates total value
 value_total = SUMX(data, data[value])

 //amount_rt measure calculates running total multiplied by value
 amount_rt =  
    VAR cur_date = MAX(data[date])
    VAR rt = CALCULATE( 
                        [amount_total],
                        FILTER( 
                                 ALL(data),
                                 data[date] <= cur_date
                        )
    )        
    RETURN rt * [value_total]

Result:

enter image description here

Upvotes: 1

Related Questions