6 Replies Latest reply on Oct 30, 2018 8:43 AM by Natalie Crow

# How do you compare 2 things of the same measure/dimension?

I have a list of people and places. There's multiple people assigned to multiple places so I created a calculation that would list all of the people at each location. Now I am trying to use parameters as filters to 1. select a person and all the places will appear - and still list the other people at that place 2. select 2 different people and it will show the places they have in common - and list any other people. Any ideas?

Original Data Example:

RowPlacePerson
1TorontoJeff
2TorontoBob
3TorontoJames
4MontrealFred

What I have now Example:

PlacePerson
TorontoJeff, Bob, James
MontrealFred

What I want example - if have a filter/parameter for person 1 and a filter/parameter for person 2 and I choose Jeff and Bob then it would pull up the shared place (Toronto) and include an additional shared person (James) if there are any:

PlacePerson
TorontoAnd James

Also attached a workbook if that helps - version 10.5.1!

Thanks a bunch.

• ###### 1. Re: How do you compare 2 things of the same measure/dimension?

Will your actual application be using excel?

I can do this very nicely with LOD.  But I get this error:

If you're not doing excel in your actual application, use that calc.  Then filter for all places where that calc is greater than zero.  (That calc will get a value at the level of [Place].  Each [Place] will have its own value.)

1 of 1 people found this helpful
• ###### 2. Re: How do you compare 2 things of the same measure/dimension?

If you're using excel, I got this calc to work:

LOOKUP( WINDOW_SUM(SUM( IF [Person] = [Parameters].[Choose Person 1]

or [Person] = [Parameters].[Choose Person 2] then 1 else 0 END))>0 ,0)

Run it along [Person] like your other table calcs.  You'll get True or False for whatever [Place] has either of the selected persons.

BTW, I do these strings lists a little differently.  I grab a WINDOW_MAX of the growing string (which is usually the LAST() one anyway, which is what you were doing with your filter.)  So there is a MINDOW_MAX on all rows, and then I filter for INDEX()=1.

So that's what you see in the attached example.  Drag the [Get Persons] calc onto filters, and select for TRUE.

1 of 1 people found this helpful
• ###### 3. Re: How do you compare 2 things of the same measure/dimension?

My actual application uses the Tableau Server not excel. However, I tried the calculation with this sample data and with my actual data and while the calculations were valid, they did not give the solution. Can you please paste your result when you have that calculation on?

• ###### 4. Re: How do you compare 2 things of the same measure/dimension?

Natalie Crow wrote:

... Can you please paste your result when you have that calculation on?

What do you mean by the bolded part?

Given that I only have an excel file to work with, I can only get an error for the LOD calc.

Did you look at the sample workbook I uploaded?  (Names A.twbx)

What happens when you use the table calc I did?

• ###### 5. Re: How do you compare 2 things of the same measure/dimension?

Oh my bad - I didn't see the attached workbook. That helps a lot! Using that as a guide and the LOD calc with my real data I think I'm gonna be able to work through it from there. Thanks soooo mcuh for all the help!! I appreciate it.

• ###### 6. Re: How do you compare 2 things of the same measure/dimension?

I also used this formula. Just in case this will help anyone else who comes across this question:

IF [Choose Person 1] = "All" AND [Choose Person 2] = "All"

THEN "IN"

ELSEIF CONTAINS([List of People], [Choose Person 1]) and [Choose Person 2] = "All"

THEN "IN"

ELSEIF [Choose Person 1]<> "Null" and CONTAINS([List of People],[Choose Person 2])

THEN "IN"

ELSE "OUT"

END