Forum Discussion
Need help with Running Total
I am struggling to understand how to calculate a running total. I have a columns with customer IDs, week numbers and a number of sessions per week. I would like to calculate a running total of the number of sessions per customer.
What I've done so far is
RT Sessions = CALCULATE(sum(Query1[Sessions]),filter(all(Query1[concat sessions]),Query1[concat sessions]<=MAX(Query1[concat sessions])))Sessions is the count of sessions per week. Concat sessions is the week numbers. As it is, it's just giving me the number of sessions each week, but I need this to be running total.
Sorry, I am very new to DAX and Power BI.
10 Replies
- amitchandak
Super User
tpoltorak , Try like
RT Sessions = CALCULATE(sum(Query1[Sessions]),filter(all(Query1) ,Query1[concat sessions]<=MAX(Query1[concat sessions]) && Query1[customer] =max(Query1[customer] )))
- tpoltorak
Helper I
When you are saying Query1[customer] do you mean customer ID's? Then selecting a max customer ID doesn't make sense in my head. Sorry. 🙂
- amitchandak
Super User
tpoltorak , Yes. I was not sure about the column name. I want that work within the same customer ID
- tpoltorak
Helper I
I am really sorry, but I am still struggling to understand the code for Running Total. I have tried several YouTube videos and code but none of it works. In the following example, can you please tell me, what is the correct code to calculate the running total of Sessions per ID?