Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Compare values within a percentage tolerance

I have a price for a product which I want to compare with another price (e.g. band1_price from a set of price bandings) with a tolerance, say of 1%. Instead of an exact match with = it needs to be within 1% either side. The equivalent of:

if(band1_price * 9.99 < product_price < band1_price * 1.01,'As Band 1','Probably more ifs here for more than and less than')

Can anyone tell me what the syntax is please?

Thanks, Jackie

3 Replies
sunny_talwar

May be something like this:

If((band1_price * 0.0099) < product_price and (band1_price * .0101) > product_price, 'Band 1') as BandField

Not applicable
Author

Thanks Sunny. I came to the same conclusion in the end, but was hoping for something a little more concise, like when you can set date ranges with startdate < datefield < enddate. As I'm comparing with a number of bands its a nested if, so will be quite long-winded.

sunny_talwar

Depending on your band, you might only need upper conditions because the if statement is executed in the order of condition. If the first condition is met, it won't give you a result past that. (Note: First condition might still need two checks)