7 Replies Latest reply on Nov 22, 2017 5:18 AM by Brent Mathison

# Calculated Field that sums from Week 1

My viz displays a sum of tests performed for a financial year but in week blocks e.g. Week 5, Week 6 etc. What I would like to do is create and insert a calculated field below "Week Number" that displays the total number of tests performed from Week 1 up to the week numbers i am displaying on my viz. I have tried running total but if i display only week 19, week 20 and week 21 the running total starts from week 19 which displays 56, 90 and 158 whereas I need the calculation to always start from week 1. The number of tests in the below image are correct for each week but the correct total from week 1 to week 21 is 1,056. I am using Tableau desktop v10.3

• ###### 1. Re: Calculated Field that sums from Week 1

Hi Steven. When I need to show a running total from the beginning, I hide my unneeded data rather than filtering it. For example:

Create a parameter to input the beginning week number to display

[Parameter week number] (Integer)

Then create a calculated field:

[Week Show/Hide]=

IF [Week Number]<[Parameter week number] THEN 'Hide' ELSE 'Show' END

Add [Week Show/Hide] to the front of your Columns shelf, then hide the 'Hide' values. Make sure your running total table calculation is set to calculate at the Table Across level.

1 of 1 people found this helpful
• ###### 2. Re: Calculated Field that sums from Week 1

And here's a sample workbook with that concept implemented.

• ###### 3. Re: Calculated Field that sums from Week 1

Hi Brent

Thanks for your help. I downloaded your sample and it is exactly what I am looking for but for some reason I cannot get it to work on mine. I am wondering if it has something to do with me having a date filter. In the below image i change the parameter to 20 and the week columns do not hide unless I untick the "Hide" checkbox. If I do that then the running total doesn't calculate correctly.

• ###### 4. Re: Calculated Field that sums from Week 1

Hi Brent

This is the result if I enter 20 for the parameter and untick Hide

• ###### 5. Re: Calculated Field that sums from Week 1

The trick is that you are not actually filtering the data - you are hiding it. Remove [Week Show/Hide] from your filters pane, then right-click "Hide" in your column headers and select "Hide"...like this:

• ###### 6. Re: Calculated Field that sums from Week 1

Hi Brent

Thanks, I misunderstood your original directions. Using your latest instructions I now have it working. Thanks and much appreciated.

• ###### 7. Re: Calculated Field that sums from Week 1

You're welcome - glad it worked!