Andrew Neeld Andrew Neeld - 2 years ago 184
SQL Question

Tableau Calculated Field to Display Placement in Sort Order

I am making a dashboard to rank the performance of employees based on around 20 metrics. I am wondering if I can create a calculated field that will output the placement they have in a descending sort of that metric.

For example, if they are 13th out of 20 employees based on accuracy, the field would output 13.

Is this possible?

Thank you,


Answer Source

I think you're just looking for the rank function: rank([metricname]), assuming that metricname is the result of an aggregation. If not, wrap [metricname] in whatever function is applicable (i.e. sum, max, etc)

By default, rank() works in descending order, although this can be changed by passing in the asc argument after the expression.

To make this dynamic: Create a parameter that contains all of your metric names, along with a metric that says IF [parametername] = "metric1" then [metric1] ELSEIF [parametername] = "metric2" then [metric2] END and use that as the argument within the call to rank()

Here's an article that explains this very well:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download