问题
I have a table that looks like:
id aff1 aff2 aff3 value
1 a x b 5
2 b c x 4
3 a b g 1
I would like to aggregate the aff columns to calculate the sum of "value" for each aff. For example, the above gives:
aff sum
a 6
b 10
c 4
g 1
x 9
Ideally, I'd like to do this directly in tableau without remaking the table by unfolding it along all the aff columns.
回答1:
You can use Tableau’s inbuilt pivot method as below, without reshaping in source .
- CTRL Select all 3 dimensions you want to merge , and click on pivot .
- You will get your new reshaped data as below, delete other columns :
- Finally build your view.
I hope this answers . Rest other options for the above results include JOIN at DB level, or creating multiple calculated fields for each attribute value which are not scalable.
来源:https://stackoverflow.com/questions/34427353/aggregating-from-multiple-columns-in-tableau