Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
realpixel
Creator
Creator

Find and Replace function

Hello,

I want to use a replace function to find and replace a value by another.

For example

[CUSTOMER]         

customer1

customer2

customer3

customer4

customer5

customer6

customer7

customer8

customer9

customer10

customer11

customer12

.

.

.

customer1,2 and 3 must be replaced by customer1

customer 4,5,6 must replaced by customer4

and

customer 7,8,9 must replaced by customer7

24 Replies
Not applicable

hi

try this

a:

LOAD * INLINE [

    CUSTOMER

    customer1

    customer2

    customer3

    customer4

    customer5

    customer6

    customer7

    customer8

    customer9

    customer10

    customer11

    customer12

];

LOAD CUSTOMER,

    Pick(

        Match(CUSTOMER,'customer1','customer2','customer3',

                        'customer4','customer5','customer6',

                        'customer7','customer8','customer9'),

                                    'customer1','customer1','customer1',

                                    'customer4','customer4','customer4',

                                    'customer7','customer7','customer7')  as CUSTOMER_new

Resident a;           

DROP Table a;                       

realpixel
Creator
Creator
Author

Thank you for your reply, but I have forgot something

The column [CUSTOMER] and [CODE] contain 12100 rows.

I need to do this operation.

If column [CODE] contain the value A, customer1, customer2 and customer3 must be replaced by customer1

If column [CODE] contain the value A, customer4, customer5 and customer6 must be replaced by customer4

If column [CODE] contain the value A, customer7, customer8 and customer9 must be replaced by customer7

[CUSTOMER]        

 

customer1               A

customer2               A

customer3               A         

customer4               B

customer5               B              

customer6               C    

customer7               D

customer8               D         

customer9               D

customer10             E

customer11             E

customer12             E

.

.

.

perumal_41
Partner - Specialist II
Partner - Specialist II

Hi

use this script

a:

LOAD * INLINE [

    CUSTOMER,Code

    customer1,A

    customer2,A

    customer3,A

    customer4,B

    customer5,B

    customer6,C

    customer7,D

    customer8,D

    customer9,D

    customer10,E

    customer11,E

    customer12,E];

LOAD CUSTOMER,

if(Code=peek(Code),Peek(CUSTOMER1),CUSTOMER) as CUSTOMER1,

  Code

Resident a order by CUSTOMER;           

DROP Table a;  

realpixel
Creator
Creator
Author

I try the code under wthout success.

[LIEU POS]         [TRANS]

TOT CON              SV-CON

TOT  ET P             SV-CON

TOT ET P CON      SV-CON         

customer4               B

customer5               B              

customer6               C    

customer7               D

customer8               D         

customer9               D

customer10             E

customer11             E

customer12             E

a:

LOAD * INLINE [

    'LIEU POS','TRANS'

    'TOT CON','SV-CON'

    'TOT  ET P','SV-CON'

    'TOT ET P CON','SV-CON'];

LOAD 'LIEU POS',

if(TRANS)=peek(TRANS),Peek(TOTAL CONGO),'LIEU POS') as 'TOT CON',

Resident a order by 'LIEU POS';          

DROP Table a;  

perumal_41
Partner - Specialist II
Partner - Specialist II

Now try

[LIEU POS]         [TRANS]

TOT CON              SV-CON

TOT  ET P             SV-CON

TOT ET P CON      SV-CON         

customer4               B

customer5               B              

customer6               C    

customer7               D

customer8               D         

customer9               D

customer10             E

customer11             E

customer12             E

a:

LOAD * INLINE [

    'LIEU POS','TRANS'

    'TOT CON','SV-CON'

    'TOT  ET P','SV-CON'

    'TOT ET P CON','SV-CON'];

LOAD 'LIEU POS',

if(TRANS)=peek(TRANS),Peek([TOT CON]),'LIEU POS') as [TOT CON],

Resident a order by 'LIEU POS';          

DROP Table a;  

realpixel
Creator
Creator
Author

Error in expression:

If takes 2-3 parameters

LOAD 'LIEU POS',

if(TRANS)=peek(TRANS),Peek([TOT CON]),'LIEU POS') as [TOT CON],

Resident a order by 'LIEU POS';          

perumal_41
Partner - Specialist II
Partner - Specialist II

TRy this Expression

a:

LOAD * INLINE [

    LIEU POS ,TRANS

    customer1,A

    customer2,A

    customer3,A

    customer4,B

    customer5,B

    customer6,C

    customer7,D

    customer8,D

    customer9,D

    customer10,E

    customer11,E

    customer12,E];

//LOAD CUSTOMER,

//

// if(Code=peek(Code),Peek(CUSTOMER1),CUSTOMER) as CUSTOMER1,

//

//  Code

//

//Resident a order by CUSTOMER;           

//

//DROP Table a;  

a:

LOAD [LIEU POS],

if(TRANS=peek(TRANS),Peek([TOT CON]),[LIEU POS]) as [TOT CON],

TRANS

Resident a order by [LIEU POS];         

DROP Table a; 

realpixel
Creator
Creator
Author

Thank Perumal A for your assistance, the script seems to work but I don't understand something.

why table 'a' and 'a-1' are created when I apply this script? Table 'a' return no information and table 'a-1' return 'TO CON'

I try to explain, this script create a field [TOT CON] which contain the result of converting 'TOT  ET P' and 'TOT ET P CON' to 'TON CON' but these other value contain in [LIEU POS] (there is 12100 rows) not appears in the field [TOT CON].

I need that the othe value contain in [LIEU POS] are transfer to [TOT CON] without modification.

I hope that these explanation are clear

perumal_41
Partner - Specialist II
Partner - Specialist II

Hi

is possible little briefly explain ,I couldn’t understand what your requirements.

Regards

Perumal A