3

I would like to average N by Type for values of Inst

My data is set up as:

Type, Inst, N
A, A1, 4
A, A1, 13
A, A1, 13
A, A2, 4
A, A3, 5
B, B1, 4
B, b2, 10

So I would like to see a table (or bar chart) with A: 13, B:7. Any suggestions? If I put AVG(N) in rows and Type in columns I get A: 7.8, B:7

The problem is that Tableau is averaging all N per Type, but I want the numerator to be the total N for the Type while the denominator is the number of unique Inst within that Type

As3adTintin
  • 2,406
  • 12
  • 33
  • 59

2 Answers2

6

Create a calculated field desired_avg as

{FIXED [Inst] : SUM([N])}

put it in the sheet .

select aggregation as AVG and not SUM

Let me know if that worked !

minatverma
  • 1,090
  • 13
  • 24
2

Define the following calculated field

Sum(N) / countd(Inst)
Alex Blakemore
  • 11,301
  • 2
  • 26
  • 49
  • thanks, suggestions if i wanted a median instead of avg? – As3adTintin Feb 16 '16 at 15:18
  • Could just be Median(N) -- if you don't care about multiple instances of the same type being treated as distinct values. Otherwise, you'll have to think about what exactly you want the Median to represent and define the calculation accordingly. – Alex Blakemore Feb 16 '16 at 17:48