1
votes

There is some data:

A, B, C (where C = A/B)
10, 20, 0.5
10, 100, 0.1

There are two ways of counting the average C:

  • First is sum(A)/sum(B), that gives C equal 20/120=0.1666

This is Tableau: sum([A])/sum([B])

  • Second is avg(C), that gives C equal (0.5+0.1)/2=0.3

This is in Tableau: No Idea...

Both have different usages. I need the second one, but can't find a way to calculate it. Anything I try, I always get the first type.

1

1 Answers

2
votes

You are correct. In your first method, tableau is calculating the calculated field C by summing values according to the dimensions you are partitioning on in your view.

In your second option, you need to tell tableau to calculate column C (or define a different column D) for every row of the data, no sums involved. Simply: [A]/[B].

Then when you AVG column C (or D) you will get the average of all A/B values, instead of SUM(A)/SUM(B). You can get the average of column D by using the built in tableau AVG function instead of doing it manually