Apantazo
Apantazo

Reputation: 49

How to sum two different group by calculated fields in Tableau?

enter image description hereI have two calculated fields (HomeScore, AwayScore) and I grouped them by different dimensions(Home, Away). Now, I have TotalRuns per Team both in HomeGames and AwayGames. My problem is that I want to find the sum of TotalRuns per Team not separetely for home games and away games. I want to add these group-by fields somehow. I attach a screenshot to see my work. For example first column for both charts is "Arizona Diamondbacks" which has 263 Runs in first chart and 337 in the second one. I want to show the 263+337=600 Runs. Any Idea?

Upvotes: 0

Views: 6818

Answers (1)

Luke B
Luke B

Reputation: 371

You'll want to create a LOD expression.

{FIXED [Team Name] : SUM([Total Runs])}

Think of your data as a big table (which it technically always is in Tableau). Every grouping, filter, etc. that you do narrows down the number of columns and rows you have left until you are left with your data set that contributes to your chart. LOD expressions allow you to back out of the filters, etc. in your calculation. In this case, you narrowed down to home or away games, and we are backing out of that to get a bigger picture of the data.

Upvotes: 1

Related Questions