Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Qlik Sense - Joining 2 tables, using an expression

Hello,

I would very much appreciate you help in solving this case:

I have these 2 tables which I would like to join, using a "wild" match between the Location (e.g. FR-PARIS) and the Expression (e.g. FR-*) so that I can associate the Group to the Order (e.g. FRANCE) :

Order:

ORDERIDAmountLocation
150FR-PARIS
220FR-NICE
312IT-ROME
456IT-MILAN

Grouping:

GroupExpression
FRANCEFR-*
ITALYIT-*

I would like to obtain this table at the end:

OrderWithGrouping:

ORDERIDAmountLocationGroup
150FR-PARISFRANCE
220FR-NICEFRANCE
312IT-ROMEITALY
456IT-MILANITALY

I am creating the 2 first tables above this way:

Order:

Load * inline

[ORDERID, Location,  Amount

1,       FR-NICE,   200      

2,       FR-PARIS,  100

3,       IT-ROME,   300

4,       IT-VENISE, 400

];

Grouping:

Load * inline

[Group,  Expression

FRANCE, FR-*

ITALY,  IT-*

];

I don't know how to join these 2 tables in order to join them and obtain the above table OrderWithGrouping

It would be very helpful if you could give me some advice. Many thanks

Annick

1 Solution

Accepted Solutions
martin_dideriks
Partner - Contributor III
Partner - Contributor III

Have a look at the example from Rob Wunderlich:Mapping with wildcards.

http://qlikviewcookbook.com/download/mapping-with-wildcards/

View solution in original post

7 Replies
Gysbert_Wassenaar

Perhaps like this:

mapCountry:

LOAD * INLINE [

Substring, Country

FR, FRANCE

IT, ITALY

];

Order:

LOAD

     *,

     applymap('mapCountry', subfield(Location, '-',1)) as Country

FROM

     ...

     ;


talk is cheap, supply exceeds demand
Michael_Tarallo
Employee
Employee

Hi Annick,

Take a look at this as well.

let us know ho you do

Please mark the appropriate replies as CORRECT / HELPFUL so our team and other members know that your question(s) has been answered to your satisfaction.

Regards,

Mike Tarallo

Qlik

Regards,
Mike Tarallo
Qlik
Not applicable
Author

Hello Gysbert,

Thanks a lot for your reply. Indeed your answer is correct and works for the particular scenario that I have described. However I should have mentioned that I would like to support different types of expressions.

For example "FR-*" and "**-MARSEILLE".

I could have :

Order:

ORDERIDAmountLocation
150FR-PARIS
220FR-NICE
312IT-ROME
456IT-MILAN
534XX-MARSEILLE

Grouping:

GroupExpression
FRANCEFR-*
ITALYIT-*
MRS**-MARSEILLE

I would like to obtain this table at the end:

OrderWithGrouping:

ORDERIDAmountLocationGroup
150FR-PARISFRANCE
220FR-NICEFRANCE
312IT-ROMEITALY
456IT-MILANITALY
534XX-MARSEILLEMRS

Thanks

Kind regards

Not applicable
Author

Hello Michael,

I have added some precisions to my initial request. I will check the video and see if it helps !

Thanks a lot.

Annick

Gysbert_Wassenaar

Ok, try this then:

mapGroup:

LOAD * INLINE [

Substring, Group

FR, FRANCE

IT, ITALY

MARSEILLE, MRS

];

Order:

LOAD

     *,

     applymap('mapGroup', subfield(Location, '-',1), applymap('mapGroup', subfield(Location, '-',-1) ) as Group

FROM

     ...

     ;


talk is cheap, supply exceeds demand
martin_dideriks
Partner - Contributor III
Partner - Contributor III

Have a look at the example from Rob Wunderlich:Mapping with wildcards.

http://qlikviewcookbook.com/download/mapping-with-wildcards/

Not applicable
Author

Thanks a lot! It does work. However for now, I think I will implement the formula provided below by Martin as it is more generic and my expression might evolve. Thanks a lot for your time. Annick