Forum Discussion

tpoltorak's avatar
tpoltorak
Icon for Helper I rankHelper I
5 years ago

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

  • 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's avatar
      tpoltorak
      Icon for Helper I rankHelper 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. 🙂

  • 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?