Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Mapping, ApplyMap or MapSubstring ?

Hello all,

I´m with a doubt about a "fiel update".

For example, I have a table:

AGES:

LOAD * INLINE [
    NAME, AGE
    JOHN, 20
    BILL, 25
    PAUL, 30
]
;

 

CORRECT:

LOAD * INLINE [
    NAME, AGE
    BILL, 55
]
;

As result, I want this:

NAME, AGE

JOHN, 20

BILL, 55

PAUL, 30.

What better way to do this ?

Best Regars,

1 Solution

Accepted Solutions
Gysbert_Wassenaar

Applymap is your friend here I think:

CORRECT:

Mapping LOAD * INLINE [
    NAME, AGE
    BILL, 55
]
;

AGES:

LOAD NAME, applymap('CORRECT',NAME,AGE) as AGE;

LOAD * INLINE [
    NAME, AGE
    JOHN, 20
    BILL, 25
    PAUL, 30
]
;

 


talk is cheap, supply exceeds demand

View solution in original post

8 Replies
Peter_Cammaert
Partner - Champion III
Partner - Champion III

Just one of multiple ways to do this. Add the following to the end of your script:

CORRECTED_AGES:

LOAD * RESIDENT CORRECT;

CONCATENATE (CORRECTED_AGES)

LOAD * RESIDENT AGES

WHERE NOT EXISTS(NAME);

DROP Table AGES;

RENAME Table CORRECTED_AGES TO AGES;

Best,

Peter

Not applicable
Author

Dear Peter,

I can´t use Resident in this case because I have millions rows.

For this i need a function.

Tks,

Not applicable
Author

Dear Peter,

I can´t use Resident in this case because I have millions rows.

For this i need a function.

Tks,

Gysbert_Wassenaar

Applymap is your friend here I think:

CORRECT:

Mapping LOAD * INLINE [
    NAME, AGE
    BILL, 55
]
;

AGES:

LOAD NAME, applymap('CORRECT',NAME,AGE) as AGE;

LOAD * INLINE [
    NAME, AGE
    JOHN, 20
    BILL, 25
    PAUL, 30
]
;

 


talk is cheap, supply exceeds demand
Peter_Cammaert
Partner - Champion III
Partner - Champion III

Nice one indeed.

Peter

Not applicable
Author

Thanks Gysbert,

Now its my friend hahaha

Best Regards,

Peter_Cammaert
Partner - Champion III
Partner - Champion III

As a bonus: keep in mind that a PRECEDING LOAD uses resident tables as well. They're just not that visible.

As a 2nd bonus: ApplyMap is way faster than exists(), especially with lots of data.

Peter

alis2063
Creator III
Creator III

 

U Can preform Mapping load as its  faster than join

CorrectData:

Mapping LOAD
NAME,
AGE INLINE [
NAME, AGE
BILL, 55
];


Data:
Load ApplyMap('CorrectData',NAME,AGE) AS CorrectAge,
NAME;
LOAD * INLINE [
NAME, AGE
JOHN, 20
BILL, 25
PAUL, 30
];