TABLEAU - Calculating measure as a percentage of another measure

482 Views Asked by At

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!

1

There are 1 best solutions below

1
On

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