Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi.
I pasted below a snippet of multiple If Statements that I have in my query.
We are pretty sure there is no syntax error as I merely copy paste the previous lines of code and just change the condition's value yet I am getting an error.
Please refer to screen shot below. Could there perhaps be a limitation on the number of If Statements allowed?
Please advise.
Thank you.
if(UoM = 'Single' and PackType = 'Conv',
if(Price < 8, '< 8',
if(Price = 8, '8',
if(Price > 8 and Price < 8.5, '8 - 8.5',
if(Price = 8.5, '8.5',
if(Price > 8.5 and Price < 9, '8.5 - 9',
if(Price = 9, '9',
if(Price > 9 and Price < 9.5, '9 - 9.5',
if(Price = 9.5, '9.5',
if(Price > 9.5 and Price < 10, '9.5 - 10',
if(Price = 10, '10',
if(Price > 10 and Price < 10.5, '10 - 10.5',
if(Price = 10.5, '10.5',
if(Price > 10.5 and Price < 11, '10.5 - 11',
if(Price = 11, '11',
if(Price > 11 and Price < 11.5, '11 - 11.5',
if(Price = 11.5, '11.5',
if(Price > 11.5 and Price < 12, '11.5 - 12',
if(Price = 12, '12',
if(Price > 12 and Price < 12.5, '12 - 12.5',
if(Price = 12.5, '12.5',
if(Price > 12.5 and Price < 13, '12.5 - 13',
if(Price = 13, '13',
if(Price > 13 and Price < 13.5, '13 - 13.5',
if(Price = 13.5, '13.5',
if(Price > 13.5 and Price < 14, '13.5 - 14',
if(Price = 14, '14',
if(Price > 14 and Price < 14.5, '14 - 14.5',
if(Price = 14.5, '14.5',
if(Price > 14.5 and Price < 15, '14.5 - 15', ****** This is the line with the anomaly. 'Price' does not come up in red as a field name.
if(Price = 15, '15',
Hi,
it is hard to say what is wrong with these if statements without QV document provided, but in such cases better solution would be to use IntervalMatch or Map applying in data model script.
regards
I copied your snippet into QV and I got no errors (using QV11 desktop). So not sure what is causing your problems.
But I think there are better solutions anyway, for example
if(Price < 8,'<8',
if(Price >15, '>15',
if(Price = floor(Price),Price,
Replace(class(Price,0.5),'<= x <',' - ')
))) as PriceRange
You could also consider using a mapping table (there are some threads about this here in the forum).
Hope this helps,
Stefan
Hi.
Thank you for the suggestion.
We did try it but without much success either. Eventually I just created a list of variables with each referencing a different range of prices and its working thus far.
Thank you once again.
Regards,
Ashley.
Hi.
Thank you for your response.
Well thats the weird thing. On my colleagues machine, it crashes on a different line as compared to my machine.
Well we tried a range of these options but eventually, it starts giving error messages.
Eventually I just created a list of variables with each referencing a different range of prices and its working thus far.
Thank you once again.
Regards,
Ashley.
Hi.
Almost 30 nested if() statements! I think its awesome for a such script interpreter.
Although, the thing that it's not colorized it doesn't mean that it can't run it.
I guess, limitations depends on many things: QV version, platform memory, the complexity of script and so on.