3 Replies Latest reply on Aug 8, 2016 9:09 AM by swaroop.gantela

# Return nearest value

Hello,

I have a dataset that looks something like this:

Values in table 1Values in table 2Closest Value
153.43153.2153.44
543.55153.44
33.45154.6
53.26154.7

What I need to do is have Tableau look at the value in Table 1, then scan the Table 2 column to identify the closest value, and then return that value.

To quote many who have gone before me "I feel like this is something Tableau should be able to do..." haha.

Any help would be greatly appreciated!

Thanks

• ###### 1. Re: Return nearest value

Are you looking for this?

Please check attached sample workbook and let me know.

Thanks and regards,

Rohan Malusare.

• ###### 2. Re: Return nearest value

I've tried to get the closest value as per your requirement. Have a look and let me know If you've any query.

Workbook (version 9.3) has been attached for your reference.

Mahfooj

• ###### 3. Re: Return nearest value

Jonathan,

I may not have caught the gist,

but I had the feeling that you are going to need to do a self-join to get every

combination of Table1 value with every Table2 value.

The difference equation is

WINDOW_MIN(MIN(ABS([Distance])))

where Distance is

[Table1]-[Table2 (Sheet1\$1)]

And then the closest is

IF ATTR([Table2 (Sheet1\$1)])=

(IF ATTR(ABS([Distance]))=[MinDistanceTable2]

THEN ATTR([Table2 (Sheet1\$1)])

END)

THEN ATTR([Table2 (Sheet1\$1)])

END