10 Replies Latest reply on Apr 7, 2016 11:30 PM by Daniel Safai

# Calculating running sum across dimensions

Hi Tableau Community,

How do I calculate a running sum while keeping the original measure in the same table?

Let me illustrate:

My question is: How do I get the highlighted numbers beneath the names for each "Team"?

I'm open to alternative representations as i know this contradicts with the way tableau works. However, it should be clear how much the running sum is for each "Team" in the view.

Thank you in advance.

Kind regards.

• ###### 1. Re: Calculating running sum across dimensions

Hi Daniel!

You can create a calc like:

if sum([Score]) = sum({fixed [Team] : sum([Score]) }) then running_sum(sum([Score])) else sum([Score]) end

Basically saying if score is a total score per team then do a running_sum of the score otherwise keep the score per name per row:

Then instead of using the original score in the view, use the new calc like shown below:

1 of 1 people found this helpful
• ###### 2. Re: Calculating running sum across dimensions

You dont need to create any calculated field. Try this

you subtotal will be like this

Mahfooj

• ###### 3. Re: Calculating running sum across dimensions

Hi Pooja!

Thank you so much for your quick and detailed answer. Given my explanation it works absolutely wonderfull, but in my data the first two groups only have one person in them causing the calculation to fail. How do you update the "if" statement to account for that?

Kind regards,

Daniel

• ###### 4. Re: Calculating running sum across dimensions

Hi Mahfooj,

Thank you for your answer, but the running sum needs to accummulate for each "Team" such that the total in "Team B" is "Team A"+"Team B".

Kind regards.

• ###### 5. Re: Calculating running sum across dimensions

oh yes, I forgot about the 1 record limitation. Change the formula to:

if sum([Number of Records]) > 1 then running_sum(sum([Score])) else sum([Score]) end

A good trick I learnt from Adam Crahen

1 of 1 people found this helpful
• ###### 6. Re: Calculating running sum across dimensions

Great suggestion, but now the total in the second group with one team member isn't summing

It should be 24 as the first calculation gives...

We are so close here

Kind regards,

Daniel

• ###### 7. Re: Calculating running sum across dimensions

Oh silly me!

You can just do running_sum(Sum(score)) and compute that using team:

1 of 1 people found this helpful
• ###### 8. Re: Calculating running sum across dimensions

Hi Pooja,

Ah of course. Excellent! You are awesome. Thank you so much. I owe you one

Kind regards,

Daniel

• ###### 9. Re: Calculating running sum across dimensions

You're welcome! It is very easy to complicate things sometimes

• ###### 10. Re: Calculating running sum across dimensions

It sure is!