Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

vlookup function in QlikView

QlikView folks,

I have a question of vlookup funtion in Qlikview. I see some discussions here, but what i am looking for is the expression to be used in a chart.

Here's an example

MEASURERATESTAR 1STAR 2STAR 3STAR 4STAR 5
A80%00.730.790.850.96
B40%00.250.50.610.8
C70%00.430.640.740.83
D22%00.660.80.850.89

The 'RATE' is calculated in chart so it is dynamic. The Star1-5 are static. But they have different threshold.

Currently I use the expression below to get the star score.

IF(RATE<STAR2,1,IF(RATE<STAR3,2, IF(RATE<STAR4,3, IF(RATE<STAR5,4,5))))

But the data itself has 20m+ records, and there are several other tables. Nested IF statements make it very slow. I was wondering if there's way alternative to if statements.

Then i came up with the vlookup idea. Although the rate is dynamic calculated, but there are limited values, it could only be 0 to 1. If i can round the rate to 0.001 level, and have a lookup table for it. As table attached. Then all i need to do is to find the value associated with the rate( as attached Excel table). I tried to use fieldvalue and fieldindex function, but it didnt work. Maybe i did not do it right.

Also one thing i need to mention is that 'MEASURE' here is dimension. And only function with set analysis doesnt work either.

Please help.

1 Solution

Accepted Solutions
flipside
Partner - Specialist II
Partner - Specialist II

You can probably just create an expression to subtract the star score at each level from the rate and determine if the value is positive (1) or negative (0) using a formula like this ...

=ceil((Rate-Star1))
+
ceil((Rate-Star2))
+
ceil((Rate-Star3))
+
ceil((Rate-Star4))
+
ceil((Rate-Star5))

... rather than using if statements or lookups.

flipside

View solution in original post

6 Replies
flipside
Partner - Specialist II
Partner - Specialist II

You can probably just create an expression to subtract the star score at each level from the rate and determine if the value is positive (1) or negative (0) using a formula like this ...

=ceil((Rate-Star1))
+
ceil((Rate-Star2))
+
ceil((Rate-Star3))
+
ceil((Rate-Star4))
+
ceil((Rate-Star5))

... rather than using if statements or lookups.

flipside

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

You don't need to do a lookup, just link the tables together on the MEASURE and RATE fields. In your MESURE_REFERENCE_TEST table, change the column name of RATE_LOOKUP to RATE to match your fact table. Then the expression to retrieve the value is =STAR_LOOKUP.

-Rob

http://robwunderlich.com

Not applicable
Author

Rob,

RATE is not a dimension, so when i do this, it returns nothing but an '-'. I really hope it work, this seems so easy. Maybe i should change my reference table. But i have no idea how.

Thanks.

Not applicable
Author

Thanks, flipside. It works.

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I overlooked the fact that RATE was not dim. Great solution Flipside!

-Rob

Not applicable
Author

There are some pretty clever people on this Community, and flipside is one of them! Great solution!