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

How to search in range of numbers

Hi all,

Question about search in a range of numbers.

Let's say I have the number 2.050. I would like to find the nearest number and then select the data in the second column.

NumberData
1.000A
1.550B
1.800C
1.900D
2.000E
2.075F
3.000G

Could one you explain to me how to do this?

Cheers,

Henco

1 Solution

Accepted Solutions
danielrozental
Master II
Master II

Oh, ok, thanks Bill, here's the document again.

View solution in original post

11 Replies
danielrozental
Master II
Master II

Something like this?

Anonymous
Not applicable
Author

Thanks for your reply Daniel.

Unfortunately I'm getting an error while opening your QV document.

danielrozental
Master II
Master II

Are you working with Personal Edition?

Here are my expressions, vValue holds the value you're looking for the nearest one

Nearest Value

firstsortedvalue(Number, fabs(Number-vValue))

Data

firstsortedvalue(Data, fabs(Number-vValue))

Anonymous
Not applicable
Author

Thanks Daniel.

I'm using QV11.1 with Named User cal, so I'm not sure what the problem is.

I used your expressions, they are perfect.

Since I do have a list of numbers I would like to find, is it possible to do this without a variable?

The output I would like to have is:

Number_input
Nearest_numberData
2.0502.075F
2.8003.000G
1.8751.900D
Bill_Britt
Former Employee
Former Employee

Daniel,

I tried to open the document and I also recieved an error.

Bill

Bill - Principal Technical Support Engineer at Qlik
To help users find verified answers, please don't forget to use the "Accept as Solution" button on any posts that helped you resolve your problem or question.
danielrozental
Master II
Master II

Are the tables associated at all? If believe it should work anyway

danielrozental
Master II
Master II

Oh, ok, thanks Bill, here's the document again.

Anonymous
Not applicable
Author

Thanks, that works for me.

In the help I read this:

If more than one value of expression share the same lowest sort-order, the function will return NULL.

By stating an n larger than 1, the nth value in order will be returned. If the word distinct occurs before the expression, all duplicates will be disregarded.

Could you please tell me how to add this to the expression?

Thanks a lot.

danielrozental
Master II
Master II

You can see that in the help samples.

firstsortedvalue ( distinct PurchasedArticle, OrderDate )

If you have problems with ties just add a rand() to the input values or something like that.