Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
beck_bakytbek
Master
Master

MapSubString only distinct value

Hi Folks,

 

i got a situation: i have two tables and i am using the function: MapSubString ()

map2:

mapping LOAD * Inline

[ AttCode, Attribute

R, Red

C, Cotton

B, Blue

P, Polyester

L, Large];

 

 

Productmodels:

LOAD *,

MapSubString('map2', AttCode) as Description

Inline [

Model, AttCode

Twixie, R C R

Boomer, B P L

];

 

and final tables does look like:

Model          Description

Twixie,   Red Cotton Red

Boomer, Blue Polyester Large

 

if you see the Model: Twixie has 3 values in Description: Red, Cotton, Red,

 

it is possible to show only the distinct value, for instance: Twixie, Red, Contton ?

 

Does anybody have any idea?

Thanks a lot

Beck

Labels (1)
1 Solution

Accepted Solutions
kaanerisen
Creator III
Creator III

Hi beck,

Try this,

map2:
mapping LOAD * Inline
[ AttCode, Attribute
R, Red
C, Cotton
B, Blue
P, Polyester
L, Large];

Master:
LOAD Model,MapSubString('map2', AttCode) as Description;
LOAD Model,Concat(distinct AttCode, ' ') as AttCode Group By Model;
LOAD Model,SubField(AttCode, ' ') as AttCode
Inline [
Model, AttCode
Twixie, R C R
Boomer, B P L
];

Untitled.png

View solution in original post

5 Replies
rubenmarin

Hi, maybe with a middle step to split ain rows and remove duplicates:

 

CleanAttCode:
LOAD Distinct 
	*,SubField(AttCode, ' ') as Att
Inline [
Model, AttCode
Twixie, R C R
Boomer, B P L
];
 
Productmodels:
LOAD *,
MapSubString('map2', AttCode) as Description;
LOAD Model, Concat(Att, ' ') as AttCode
Resident CleanAttCode
Group By Model;

DROP table CleanAttCode;

 

beck_bakytbek
Master
Master
Author

Hi Rubenmarin,

 

thanks a lot for your responce, but your suggestion does not work

Vegar
MVP
MVP

Try adjusting @rubenmarin solution changing
Concat(Att, ' ')
to
Concat(DISTINCT Att, ' ')
kaanerisen
Creator III
Creator III

Hi beck,

Try this,

map2:
mapping LOAD * Inline
[ AttCode, Attribute
R, Red
C, Cotton
B, Blue
P, Polyester
L, Large];

Master:
LOAD Model,MapSubString('map2', AttCode) as Description;
LOAD Model,Concat(distinct AttCode, ' ') as AttCode Group By Model;
LOAD Model,SubField(AttCode, ' ') as AttCode
Inline [
Model, AttCode
Twixie, R C R
Boomer, B P L
];

Untitled.png

beck_bakytbek
Master
Master
Author

Thanks a lot for your help and feedback