简体   繁体   中英

Power BI - DAX for Rolling Sum (Running total) not working,

I'm trying to calculate the rolling sum in the MS Power BI application using DAX.

I've got the following table, and adding another column which would display the running total of the [hours] column,

在此处输入图片说明

But I'm only getting 1 distinct value to each row (grand total) with the following DAX,

RollingTotal = 
    calculate (sum('costtrackerdb timesheet'[hours]), 
                 FILTER(ALL('costtrackerdb timesheet'), 
                  'costtrackerdb timesheet'[Week] < 20),
                    values('costtrackerdb timesheet'[Week]))

Where am I going wrong..? I would potentially achieve two things,

  1. Running total hours of the entire rows
  2. Running total hours by each staff

A running total should not be solved with a calculated column but with a calculated measure.

See the following article: http://www.daxpatterns.com/cumulative-total/

In case your Running Total is not date Related then you could implement something like this: https://javierguillen.wordpress.com/2011/12/13/rolling-sum-across-categories-that-are-not-dates/

Here I am Calculating Running Inventory (ie Running total of inventory),I Hope it will help.

Running total = CALCULATE(SUM(Query1[Inventory Quantity]),FILTER(ALLSELECTED(Query1),Query1[DocDate]<=MAX(Query1[DocDate]))

)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM