Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

cancel
Showing results for 
Search instead for 
Did you mean: 
shadun76
Contributor II
Contributor II

Load script - check if value is inside some range

Hi,

I've got a lot of different ranges to check. I don't like spaghetti code so is there some kind of elegant way to check if some value is inside specific range?

example is that I want to check if some telephone number is from specific provider. First I'm checking digits after dialing code than dialing code and last if phone part is inside valid range.

    

Digits after dialing codeDialing codeValid range fromValid range to
50146000060999
50146200063999
50146500068999
50147000070999
50147400081999
50148300087999

And there are more than 2000 combinations. Is there some easy way to solve this in load script?


Thanks

1 Solution

Accepted Solutions
mark6505
Partner
Partner

HI,

If you have something with the Ranges on you are probably looking at at something like the interval match function.

Mark

View solution in original post

4 Replies
MarcoWedel

Can you post your expected result based on your sample data?

thanks

regards

Marco

shadun76
Contributor II
Contributor II
Author

Sure

Here is Example set of data

     

ProviderDialing codeDigits after dialing codeValid range fromValid range to
Telekom Srbija a.d., Beograd0106304000306999
Telekom Srbija a.d., Beograd0106310000314999
Telekom Srbija a.d., Beograd0106316000327999
Telekom Srbija a.d., Beograd0106340000347999
Telekom Srbija a.d., Beograd0106352000352999
Telekom Srbija a.d., Beograd0106353000353999
Telekom Srbija a.d., Beograd0106360000363999
Telekom Srbija a.d., Beograd0106365000365999
Telekom Srbija a.d., Beograd0106370000372999
Telekom Srbija a.d., Beograd0106373000373999
Telekom Srbija a.d., Beograd0106375000378999
Telekom Srbija a.d., Beograd0106383000387999
SERBIA BROADBAND - SRPSKE KABLOVSKE MREŽE0106500000501999
ORION TELEKOM0106510000519999
BEOTELNET-ISP0106520000520999
TELENOR0106540000540999
TELENOR0106541000541999
VIP MOBILE0106599000599999
Telekom Srbija a.d., Beograd0106620000620999
Telekom Srbija a.d., Beograd010721000002100999
Telekom Srbija a.d., Beograd010721500002150999
Telekom Srbija a.d., Beograd010721570002157999
Telekom Srbija a.d., Beograd010723100002314999

Now if I check phone number I'd like to collect Provider. In case when something is not right I'd like to receive error.

1st 3 digits are Dialing code, then it comes phone part. Example below trows error for 01051250 because phone length is 5 and that is not valid for this dialing code + Valid range

Example:

  

Phone to checkProvider as result
010383251Telekom Srbija a.d., Beograd
010501221SERBIA BROADBAND
010512521ORION TELEKOM
01051250Error

So one dialing code can have different length of phone numbers following like 014 --> 5,6 or 7 and for each combination there is a different range of possible numbers.

  

Dialing codeDigits after dialing code
0106
0107
0117
0126
0127
0136
0137
0145
0146
0147
0156
0157
0165
0166
0167
0175
0176
0177

Any suggestion is appreciated

Thanks

mark6505
Partner
Partner

HI,

If you have something with the Ranges on you are probably looking at at something like the interval match function.

Mark

View solution in original post

shadun76
Contributor II
Contributor II
Author

This is it.

Thank you

here is sample code that did it for me...


Provajderi:
LOAD * INLINE [
from, to, Provajder
21000, 29999, Telekom Srbija
46000, 48999, Telekom Srbija
50000, 50999, Telekom Srbija
50000, 59999, Telekom Srbija
51000, 59999, Telekom Srbija
55000, 57999, Telekom Srbija
57000, 59999, Telekom Srbija
60000, 60999, Telekom Srbija
61000, 62999, Telekom Srbija ];

load *

FROM

(
qvd);

Left join(Telefoni)
Intervalmatch(Telefon)
LOAD from, to
RESIDENT Provajderi;

Left join (Telefoni)
LOAD * resident Provajderi;
drop table Provajderi;