10 Replies Latest reply on Apr 23, 2017 8:36 PM by vita nesvetailov

# Need help with the SUM if formula

Hello,

Since I am still fairly new to Tableau, I need help with a Sum If formula. What I need is to sum up all the \$ values except for code 0 which is the first column.

Thank you!

• ###### 1. Re: Need help with the SUM if formula

1. Analysis > Create Calculated Field

2. Make a Calculated Field: IF [Code] <> 0 THEN [Sales] ELSE NULL END

3. Add that to your sheet and select the sum aggregation

2 of 2 people found this helpful
• ###### 2. Re: Need help with the SUM if formula

Thank you for your response but the formula does not work. Am I missing something? It is saying that I am missing an identifier.

I want the formula to say if first column code=0 then do not include the sales in the total for that code

• ###### 3. Re: Need help with the SUM if formula

Hi Vita!

So there are two ways to do this!

Method 1: Drag the Code to filter and Exclude the 0 code.

This will remove the 0 code from the listing. Something like this:

Method 2: You can make a calculated field.

if [Code] = 0 THEN 0

ELSE [Value]

END

Then bring this to the column and then add the values using Analysis tab. it should look something like this:

Let me know if you have any doubts.

Thanks!

1 of 1 people found this helpful
• ###### 4. Re: Need help with the SUM if formula

{FIXED : SUM(IF CODE<>0 THEN [Sales] END}

• ###### 5. Re: Need help with the SUM if formula

Hi Vita,

Create the Calculated Field Using:

{FIXED : SUM(IF CODE<>0 THEN [Sales] END}

and Drag it to Label to get Sum of all except for Code 0.

Hope it Helps!!!

Thanks

Deepak

• ###### 6. Re: Need help with the SUM if formula

Hi Deepak, thank you for your help. It is asking for closing parenthesis or comma for SUM. I tries a few options and didn't get it to work. Any ideas?

• ###### 7. Re: Need help with the SUM if formula

There you go!

{FIXED : SUM(IF [Code]<>0 THEN [Value] END)}

1 of 1 people found this helpful
• ###### 8. Re: Need help with the SUM if formula

Hi Vita

Sorry I forgot to close it.Just put a ) after END

THanks

Deepak

• ###### 9. Re: Need help with the SUM if formula

Thanks a lot! It was helpful!

• ###### 10. Re: Need help with the SUM if formula

Thank you! It worked. I appreciate all your help