Home » Web Development » Performing SUM based on Group in Tableau

About Arpit Aggarwal

Arpit is a Consultant at Xebia India. He has been designing and building J2EE applications since more than 6 years. He is fond of Object Oriented and lover of Functional programming. You can read more of his writings at aggarwalarpit.wordpress.com

Performing SUM based on Group in Tableau

Today while working on one of my assignments I got a requirement to perform a SUM of one column values based on a Group of columns in Tableau and being a novice to Tableau I started searching on the internet to find a way to achieve it and after spending few hours I found a solution so thought of sharing over here how I did it.

Below is my data set and I want to calculate the Amount spent each Month and the Total Amount spent in all months, the Average spent, and the Percentage of the Amount spent on each category.

As a first step, I created a Calculated field and named it as AmountSpentPerMonth, and used a FIXED level of Detail Expressions with the following expression:

{FIXED [Name],[Month]:SUM([Amount])}

Next, I created another Calculated field and named it as TotalSpentForAllMonths, and used a FIXED level of Detail Expressions with the following expression:

{FIXED [Name]:SUM([AmountSpentPerMonth])}

Then I created another Calculated field and named it as AverageSpent, and used a FIXED level of Detail Expressions with the following expression:

SUM([TotalSpentForAllMonths])/TOTAL(COUNTD([Month]))

Then I created another Calculated field and named it as PercentageSpentOnEachCategory, and used a FIXED level of Detail Expressions with the following expression:

[Amount]

Moved all calculated fields on Sheet together with other data fields and changed Percentage Compute Using “Category” as shown in a screenshot below:

Published on Java Code Geeks with permission by Arpit Aggarwal, partner at our JCG program. See the original article here: Performing SUM based on Group in Tableau

Opinions expressed by Java Code Geeks contributors are their own.

Do you want to know how to develop your skillset to become a Java Rockstar?
Subscribe to our newsletter to start Rocking right now!
To get you started we give you our best selling eBooks for FREE!
1. JPA Mini Book
2. JVM Troubleshooting Guide
3. JUnit Tutorial for Unit Testing
4. Java Annotations Tutorial
5. Java Interview Questions
6. Spring Interview Questions
7. Android UI Design
and many more ....
I agree to the Terms and Privacy Policy
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments