Consider the following table. I'm trying to take the sum of the columns value1, and value2 according to their respective column names. I.e the summation for A should result in 3+6 = 9, and the summation for B should result in 5+4=10.
I have created a calculated field that takes the sum of both columns as seen below
SUM([value1]) + SUM([value2])
Ultimately, I'm trying display a bar chart, where one bar shows the total value for A, and the other bar shows the total value for B. I have placed column1 in rows, and the result of the calculated field in columns. I initially expected for tableau to sum up the values according to the field name. However it simply looks at the name in column1, and sums up value1 and value2 horizontally. In retrospect, it now makes sense why it's doing this. However I've looked through the docs extensively, and could not find a feasible solution to this. Hoping for some extra guidance!
Many thanks.
Hi James,
Find my approach as reference below and stored in attached workbook version 10.5 located in your original post here:
How to match two columns in tableau and sum the values that match
1. Pivot your datasource, Pivoting is explained here: Pivot Data from Columns to Rows - Tableau
2. 01 M Value 1+2
if [Pivot Field Values]='A' and [Pivot Field Names]='Column1' then [Value2]
elseif [Pivot Field Values]='A' and [Pivot Field Names]='Column2' then [Value1]
elseif [Pivot Field Values]='B' and [Pivot Field Names]='Column1' then [Value2]
elseif [Pivot Field Values]='B' and [Pivot Field Names]='Column2' then [Value1]
end
Thanks,
Norbert