Hassan Tahir
Hassan Tahir

Reputation: 23

Tableau: How to rank values in each category to be used in visualizations

So, I have a data set for Clients. The data set mainly has 3 columns that I am concerned with; Client Name - name of the client, Event Data - when the event was held, and Event Success - was the event a success or not. From this, first I want to rank events for each client by the event date; the event with the earliest date would be the 1st event for the client and so on. Next, I want to plot the success rate of events depending on the event number i.e. the first events are usually a 50% success while the 3rd events have a success rate of 75%.

In tableau, I have tried using the RANK function in a couple of ways to no success. It only works in table visualizations which contain measures/dimensions used in the rank formula to achieve a category-wise rank. Is there some other way to achieve this?

The following is the kind of final visual I would ideally want: Success Rate Visualization

Thank you!

Upvotes: 2

Views: 648

Answers (1)

AnilGoyal
AnilGoyal

Reputation: 26218

@Hassan I think rank function works in tableau as per context only. As soon as the visualization is changed, the results are changed also. However, this can be achieved so easily in R or python by writing a simple code. Still, if you have a low number of events say 4 (as per image of your desired visualization attached) you can do it manually by adding that many calculated fields plus one. Let me show you how.

Steps

  1. Create a calculated field (LOD) named 'First event date'
{Fixed [Client Name] : Min [Event Data]}
  1. Create Column named 'Second event date'
Second event date

{FIXED [Client name] : MIN(
IF [Event Date] > [First event date] THEN [Event Date] end)
}

3 &4. Repeat step 2 for third and last event date

  1. Create calculated field 'Event No'
IF [Event Date] = [First Event Date] THEN "First Event"
ELSEIF [Event Date] = [Second Event Date] THEN "Second Event"
ELSEIF [Event Date] = [Third Event Date] THEN "Third Event"
ELSE "Fourth Event"
END

Please check with your data and respond.

Upvotes: 1

Related Questions