3 Replies Latest reply: Feb 26, 2015 11:09 AM by Vishal Jada

# Lookup problem

Hi fellow developers,

I'm trying to do the following lookup in excel.

 Principal Band 2 0 12 12 18 18
 Band 0 10 20

I have a table that has the principal amount, and another table w/ the band values. I'm trying to create the 1st table. The basic logic is we're using principal as the lookup value against the band table to map the corresponding lookup value. Instead of doing the exact lookup, we're interested in finding the closest match. In other words Principal value of 2 is closer to band 0 than band 10 and hence belongs to Band 0. Similarly Principal value 12 is closer to band 10 than band 20, and therefore belongs to band 12.

Hope this made sense. How can accomplish this type of lookup in QlikView.

Regards

V

• ###### Re: Lookup problem

Unfortunately not the shortest solution. Suitable at the model level.

VLookUpSource:
Principal,    Band
2,    0
12,    12
18,18
]
;
T:
Something
0
10
20
]
;
Left Join(T)
Band
Resident VLookUpSource
;

NoConcatenate
T2:
Something,
FirstSortedValue(Band, Diff)
Group By Something
;
Something,
Band,
fabs(Something-Band) as Diff
Resident T
;

DROP Table T;

• ###### Re: Lookup problem

Are your band values in increments of 10? If so, you could use

round(Principal, 10)

-Rob

• ###### Re: Lookup problem

Thanks everyone for your input. This really helped.