0

I want to calculate a measure as a percentage of another measure. For example, I have a field x_users and I want to calculate the percentage of this field in relation to the total_users. Then, I would like to visualize this percentage set against total_users. I believe I can accomplish this by utilizing dual axis.

Sample dataset

Date App x_users total_users
2020-01-01 A 5 10
2020-01-02 B 3 15

Do you guys have any tips on how to proceed and then visualize this? Thank you in advance!

vtrhmd
  • 75
  • 7

1 Answers1

0

For user percentage use this calculation

[x_users]/[total_users]

EDIT -- CORRECTION - For correct behavior, use an aggregate calculation as below for ratios such as this. That will give correct results even when you further aggregate results, say by removing App from the Row shelf.


    SUM([x_users]) / SUM([total_users])

enter image description here

For data-visual, a bar-within-bar plot is suggested with labels on user percentage,

  • dual axis (on x_user)
  • synchronise axis
  • change width of bar for secondary axis data (x_user)
  • unshow header for dual axis
  • add labels (on secondary axis data i.e. x_user) for above mentioned calculated field.

enter image description here

Alex Blakemore
  • 11,301
  • 2
  • 26
  • 49
AnilGoyal
  • 25,297
  • 4
  • 27
  • 45
  • 1
    The original answer will give incorrect results in some cases. An aggregate calculation is more robust for most ratio calculations. I partially edited the answer to note that, but recommend updating the whole answer (and then removing my note). Read about aggregate calculations in the Tableau help for a better explanation. The typical example involves calculating profit ratios – Alex Blakemore Jan 29 '21 at 19:25