Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
smilingjohn
Specialist
Specialist

Logic script

Hi All ,

I have a table in it there is a field by name City which has some errors needs to be replaced , Below is the wildmatch iam tryong to use but i think iam wrong somewhere . I want the city name to be replaced as i have described  and other than that it should display all the CITY name as it is , and iam trying to create a new field by name cit. Pleas elet me know where iam wrong , This is loading but npt giving any error .Through some light on this

City:

LOAD CITY,

     if(WildMatch(CITY,'BETHLEHT*'),'BETHELEHM') ,

    if(WildMatch(CITY,'ZION HI*'),'ZIONHILL') ,

    if(WildMatch(CITY,'SCOTT TW*'),'SCOTT TOWNSHIP') ,

    if(WildMatch(CITY,'SCHUYKL HAV*'),'SCHUYLKILL HAVEN') ,

   // if(WildMatch(CITY,'S ABINGTN TWP*'),'S ABINGTON TWP'),

   if(WildMatch(CITY,'NEWBUR*'),'NEWBURG'),

    if(WildMatch(CITY,'NEW RING*'),'NEW RINGGOLD'),

    if(WildMatch(CITY,'MT BETH*'),'MOUNT BETHEL'),

    if(WildMatch(CITY,'LAURY*'),'LAURYS STATION'),

    if(WildMatch(CITY,'JERY*'),'JERMYN'),

    if(WildMatch(CITY,'HONEYBRO*'),'HONEY BROOK'),

    if(WildMatch(CITY,'HAZLE TOWNS*'),'HAZLE TOWNSHIP'),

     if(WildMatch(CITY,'EGG HBR*'),'EGG HARBOR TWP'),

      if(WildMatch(CITY,'EAST STROUDSBUR*'),'EAST STROUDSBURG'),

      if(WildMatch(CITY,'DOYLETOW*'),'DOYLESTOWN'),

      if(WildMatch(CITY,'CHARLESTO*'),'CHARLES TOWN'),

      if(WildMatch(CITY,'CATASAQ*'),'CATASAUQUA'),

      if(WildMatch(CITY,'BREININGSVI*'),'BREINIGSVILLE'),

      if(WildMatch(CITY,'BOYTON BE*'),'BOYNTON BEACH'),

      if(WildMatch(CITY,'BOILING SPN*'),'BOILING SPRINGS'),

      if(WildMatch(CITY,'SPRNG BRK*'),'SPRING BROOK TWP'),

       if(WildMatch(CITY,'PHILA*'),'PHILADELPHIA'),

        if(WildMatch(CITY,'S ABINGT*'),'S ABINGTON TWP'),

         //if(WildMatch(CITY,'SCHUYKL HAV*'),'SCHUYLKILL HAVEN'),

         if(WildMatch(CITY,'NEW PHIL*'),'NEW PHILADELPHIA'), CITY  AS cit,

1 Solution

Accepted Solutions
tresesco
MVP
MVP

The trick of ELSE part here:

Pick(wildmatch(City, 'A1*', 'B1*' , 'C1*', 'D1*', 'E1*' , 'F1*')+1, City, 'A', 'B', 'C', 'D', 'E', 'F') as [Transaction Type]

View solution in original post

11 Replies
tamilarasu
Champion
Champion

Hi,

Use pick Wildmatch in this case.

Ex: Pick(wildmatch([Type], 'A1*', 'B1*' , 'C1*', 'D1*', 'E1*' , 'F1*'), 'A', 'B', 'C', 'D', 'E', 'F') as [Transaction Type]

PrashantSangle

Hi,

You have syntax error

modify your if statement

like

if(wildmatch(City,'BETHLEHT*'),'BETHELEHM',

     if(wildmatch(City,'ZION HI*'),'ZIONHILL',City

)) as newCity

check closing bracket also for more details see if else in help menu

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this using Pick() and WildMatch(), it is bit easier when compared to Nested IF()

=Pick(WildMatch(CITY,'BETHLEHT*', 'ZION HI*', 'SCOTT TW*'), ...........................

     'BETHELEHM',

     'ZIONHILL',

'SCOTT TOWNSHIP', .................................)

Hope this helps you.

Regards,

jagan.

smilingjohn
Specialist
Specialist
Author

Ji jagan ,

Please find the attachment i tried the abive expression even replaced by and yet its not working

smilingjohn
Specialist
Specialist
Author

Hi Tamil rajan beside this it has to pic CITY , that is else CITY

settu_periasamy
Master III
Master III

Hi John,

Try this..

Load City,

if(WildMatch(City,'BETHLEHT*'),'BETHELEHM',
if(WildMatch(City,'ZION HI*'),'ZIONHILL' ,
if(WildMatch(City,'SCOTT TW*'),'SCOTT TOWNSHIP' ,
if(WildMatch(City,'SCHUYKL HAV*'),'SCHUYLKILL HAVEN' ,
// if(WildMatch(City,'S ABINGTN TWP*'),'S ABINGTON TWP'),
   if(WildMatch(City,'NEWBUR*'),'NEWBURG',
if(WildMatch(City,'NEW RING*'),'NEW RINGGOLD',
if(WildMatch(City,'MT BETH*'),'MOUNT BETHEL',
if(WildMatch(City,'LAURY*'),'LAURYS STATION',
if(WildMatch(City,'JERY*'),'JERMYN',
if(WildMatch(City,'HONEYBRO*'),'HONEY BROOK',
if(WildMatch(City,'HAZLE TOWNS*'),'HAZLE TOWNSHIP',
if(WildMatch(City,'EGG HBR*'),'EGG HARBOR TWP',
if(WildMatch(City,'EAST STROUDSBUR*'),'EAST STROUDSBURG',
if(WildMatch(City,'DOYLETOW*'),'DOYLESTOWN',
if(WildMatch(City,'CHARLESTO*'),'CHARLES TOWN',
if(WildMatch(City,'CATASAQ*'),'CATASAUQUA',
if(WildMatch(City,'BREININGSVI*'),'BREINIGSVILLE',
if(WildMatch(City,'BOYTON BE*'),'BOYNTON BEACH',
if(WildMatch(City,'BOILING SPN*'),'BOILING SPRINGS',
if(WildMatch(City,'SPRNG BRK*'),'SPRING BROOK TWP',
if(WildMatch(City,'PHILA*'),'PHILADELPHIA',
if(WildMatch(City,'S ABINGT*'),'S ABINGTON TWP',
//if(WildMatch(City,'SCHUYKL HAV*'),'SCHUYLKILL HAVEN'),
         if(WildMatch(City,'NEW PHIL*'),'NEW PHILADELPHIA'))))))))))))))))))))))) as New_City

settu_periasamy
Master III
Master III

Hi,

Instead of these much if, You can use the ApplyMap..

It is easy to maintain..

Sample attached

tamilarasu
Champion
Champion

Try like below,

Pick(wildmatch([Type], 'A1*', 'B1*' , 'C1*', 'D1*', 'E1*' , 'F1*') +1 , 'A', 'B', 'C', 'D', 'E', 'F', 'No Match') as [Transaction Type]


In your case CITY (No single quotes around the CITY)

tresesco
MVP
MVP

The trick of ELSE part here:

Pick(wildmatch(City, 'A1*', 'B1*' , 'C1*', 'D1*', 'E1*' , 'F1*')+1, City, 'A', 'B', 'C', 'D', 'E', 'F') as [Transaction Type]