9 Replies Latest reply on Aug 15, 2018 7:49 AM by Yasser Akhtar

# Want to subtract two rows

I posted this question without much success in getting an answer. I have two columns "week 29" and "week 30". Within each column are three rows 'Detractor", "Passive" and "Promoter". I want to create a third column which stores the value of "Promoter" subtracted from "Detractor". Can anyone assist?

• ###### 1. Re: Want to subtract two rows

This should be doable, but the structure of your data is important to answering the question. Any chance you can post some sample data or a packaged workbook?

• ###### 2. Re: Want to subtract two rows

Its doable. I had to create some calc's to separate out the Categories first and then do the percent change - catch I have to show at least 1 decimal place in order to be correct.

See attached sample. If you find this helpful then please mark this response correct. Thank you.

Best regards,

Ankit

• ###### 3. Re: Want to subtract two rows

Thanks Ankit, Would you be able to provide calculations here? I can't open the workbook you sent.

• ###### 4. Re: Want to subtract two rows

Hi Ken, would this help?

• ###### 5. Re: Want to subtract two rows

Which version of Tableau Desktop are you using? - the one I provided earlier was built in 10.5

• ###### 6. Re: Want to subtract two rows

Here you go: Create the below 7 calculated fields to achieve what you are looking for

Detractor

IF [NPS Cat1] = 'Detractor' THEN 1 ELSE 0 END

Passive

IF [NPS Cat1] = 'Passive' THEN 1 ELSE 0 END

Promoter

IF [NPS Cat1] = 'Promoter' THEN 1 ELSE 0 END

Detractor %

SUM([Detractor]) / (SUM([Number of Records]))

Passive %

SUM([Passive]) / (SUM([Number of Records]))

Promoter %

SUM([Promoter]) / (SUM([Number of Records]))

NPS Score %

[Promoter %] - [Detractor %]

If you find this useful then please mark so others can benefit from it.

• ###### 7. Re: Want to subtract two rows

Ankit, I am using 10.1