8 Replies Latest reply on Sep 12, 2014 8:46 AM by caitlin.donaldson

# Calculated Field not totaling

Hi,

I have a super simple calculation to get a total: [a]+[b]+[c]

The calculated field does not add aggregate the individual measures(???) any help much appreciated!

• ###### 1. Re: Calculated Field not totaling

In the extract provided, a,b, and d are all strings.  The first step is to turn them into numbers.

• ###### 2. Re: Calculated Field not totaling

Any possibility of posting a Tableau workbook (TWBX)?  That way we can see how you have the calculation setup.  I am able to add [a], [b], and [c], but it would be helpful to see how your variables are setup (are they set as measures or dimensions?) and how you are displaying the calculation.

• ###### 3. Re: Calculated Field not totaling

Change calc to SUM([a])+SUM([b])+SUM([c]) and it summed properly but why do i need to include SUM?

• ###### 4. Re: Calculated Field not totaling

How are your variables setup in your workbook?  Are they set as measures or dimensions?  You shouldn't have to put in the SUMs into your calculation.  You should only need to do that if you are mixing aggregated and non-aggregated variables into one calculation.  Can you possibly post a screenshot of what you are looking at in your workbook?  Might help to solve what is going on.

• ###### 5. Re: Calculated Field not totaling

For the test i created the TWB straight from the excel addin. Tableau placed a,b,c in the dimension section, i had to move them to the measure section and change data type, agg type (from count d to sum). I see that happening a lot. • ###### 6. Re: Calculated Field not totaling

Looking at the data I'm seeing what the problem is.  [a]+[b]+[c] is going through each row of data and summing these three numbers (so summing up row 1, then summing up what's on row 2, etc leading to summing the column).  If one of the numbers (either [a], [b], or [c]) equals null, then the total for [a]+[b]+[c] is being set equal to null.  When you add the SUMs before each variable, it tells Tableau to sum all of [a], then sum all of [b], then sum all of [c], and find out what these three added together equals instead of calculating the equation on a line by line basis.  If those nulls were instead equal to 0, I believe just typing in [a]+[b]+[c] would work.  Right click on "Sheet1 (Test.xlsx)" and click "View Data" to see what the summing looks like on a row by row basis.  Hopefully this makes sense!  If not, let me know.

• ###### 7. Re: Calculated Field not totaling

thanks so much Catilin!!!

• ###### 8. Re: Calculated Field not totaling

No problem, glad I could help!