Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Need an inverse to the Pick function

Hi All,

I'm building some fractile calculation into a tool, and while what I have currently works, it's not very fast.  What I need is a function that essentially works as an inverse to a Pick function where there are a list of possible conditions, and it returns the place the first passing condition falls in.

The way I'm doing it currently is:

- Calculate all of the max values for each decile bucket:

vE_Decile_1_max = fractile($(vE_Decile_max_Calc),0.1)

vE_Decile_2_max = fractile($(vE_Decile_max_Calc),0.2)

vE_Decile_3_max = fractile($(vE_Decile_max_Calc),0.3)

etc.

Then running it through a big if statement:

if($(vE_PP_Total_Sales) <= $(vE_Decile_1_max), 1,

if($(vE_PP_Total_Sales) <= $(vE_Decile_2_max), 2,

if($(vE_PP_Total_Sales) <= $(vE_Decile_3_max), 3,

...

While this works, it's slow.  I don't believe the class function will work either since the buckets aren't the same size.

Anyone have any ideas on how to speed this up?

Thanks!

Spencer

11 Replies
Not applicable
Author

Hi Marco,

Petter's solution actually did the trick.  Thanks for looking at this though!

Spencer

Not applicable
Author

Yes this worked perfectly!

I hadn't considered reducing the the individual comparisons to boolean and summing up individual possibilities.  Thanks for the help!