0 votes
1 view
in BI by (14.1k points)

I have a simple problem with Tableau I am not able to solve.

I would like to display a graph showing a measure over time. I would like to compare one client that the user selects through a parameter to all other clients not selected. The graph would display two lines with 2 different colors: one for the selected client, the other line for other clients. The idea is to have a benchmark.

However I would like to filter the other clients with a condition like: if vertical(other clients)=vertical(selected client) then vertical(other clients), meaning that I would like only to keep the clients that have the same vertical than the selected client. This in order to avoid the user to filter manually by selecting the vertical of the selected client.

Is it possible to do that? if yes, please let me know how!

Many thanks for your help!

1 Answer

0 votes
by (39.1k points)
  • The solution for the first part is pretty straight forward.

  • Create a calculated field called [Selected Client]. Assuming your client name is stored in [Client Name] and you created a parameter called [Client], this calculated field would be:

[Client Name] = [Client]

  • Then use it as a dimension (like dragging it to rows).

  • You can also do

IF [Client Name] = [Client] THEN [Client Name] ELSE 'Others' END

  • This way is easier to understand who is the selected client.

  • Now the second part is more tricky. I suppose you want to filter only the clients that share an attribute with the selected client (your "vertical" thing). I'm not sure this is the best solution, but it is the one I came up with.

  • First, let's change the [Selected Client] field a little bit:

IF [Client Name] = [Client] THEN '1- ' + [Client Name] ELSE '2- Others' END

  • This will help us sort on the next step. Now create a calculated field called [Filter vertical]:

LOOKUP(ATTR([Vertical]),FIRST()) = ATTR([Vertical])

  • Now, this is important. Drag Vertical to rows (before [Selected client]. Now drag [Filter vertical] to Filters. Then Edit table calculation, Compute using Advanced. Put everything to the right (Addressing), Sort Field, Selected Client, Maximum, Ascending.

  • Now with our little twist, the selected client will always be the first on the list. And our filter will keep only the clients that have the same Vertical as the first of the list (which is our client).

  • It is important to have [Vertical] on the worksheet because the table calculates partition and addresses only what is on the worksheet. If it is not there, it won't be considered.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...