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

Manual override of mappings in apply map after the groupings

I have a load sequence below which is getting me the correct values out but i want to be able to change which Mapped group some of the bname's get applied to (like a manual override as such)


Current Code:

------------------------------------------------------------------------------------------------------------------------------------------------------------------

bnewstructure:

Mapping LOAD

B_DESC AS [bname],

B_GROUP AS [bgroup]

FROM

bnewstructure:

(qvd);

MAPPING:

MAPPING LOAD * inline [

In, Out

Grouped cos, Grouped companies];

map [Mapped group] using MAPPING;

Details:

load

ApplyMap('bnewstructure:',[B name],'Missing') as [Mapped group],

*;

LOAD

boldstructure.B_DESC as [B name]

FROM

[$(vDetailsQVDDirectory)\boldstructure.qvd]

(qvd);

------------------------------------------------------------------------------------------------------------------------------------------------------------------

This outputs for example

[Mapped group]      [B name]

group1                   john

group1                   alan

group1                   paul

group2                   matt

group2                   doug


------------------------------------------------------------------------------------------------------------------------------------------------------------------

How can i manipulate the data to override which [Mapped group] a [B name] gets applied to. Do i use an if statement inside an applymap or an applymap inside an applymap etc?

------------------------------------------------------------------------------------------------------------------------------------------------------------------

For example change the above to:


This outputs for example

[Mapped group]      [B name]

group1                   john

group1                   alan

group2                   paul

group2                   matt

group2                   doug

1 Solution

Accepted Solutions
matthewp
Creator III
Creator III
Author

I solved this by doing:

bnewstructure:

Mapping LOAD

B_DESC AS [bname],

B_GROUP AS [bgroup]

FROM

bnewstructure:

(qvd);

MAPPING:

MAPPING LOAD * inline [

In, Out

Grouped cos, Grouped companies];

map [Mapped group] using MAPPING;

Details:

load

IF(match([B name],'paul'),'group2',ApplyMap('bnewstructure:',[B name],'Missing')) as [Mapped group],

*;

LOAD

boldstructure.B_DESC as [B name]

FROM

[$(vDetailsQVDDirectory)\boldstructure.qvd]

(qvd);

View solution in original post

8 Replies
matthewp
Creator III
Creator III
Author

anyone?

sunny_talwar

Would you be able to share few lines of data with expected output to help you?

matthewp
Creator III
Creator III
Author

Current output

[Mapped group]      [B name]

group1                   john

group1                   alan

group1                   paul

group2                   matt

group2                   doug


expected output


[Mapped group]      [B name]

group1                   john

group1                   alan

group2                   paul

group2                   matt

group2                   doug

sunny_talwar

Right but what data are you using to create this? Unless I have the raw data, I won't be able to help much

matthewp
Creator III
Creator III
Author

i was thinking something like editing the first mapping code from:

bnewstructure:

Mapping LOAD

B_DESC AS [bname],

B_GROUP AS [bgroup]

FROM

bnewstructure:

(qvd);

TO something like

bnewstructure:

Mapping LOAD

B_DESC AS [bname],

IF(B_DESC  = 'paul', 'group2', B_GROUP) AS [bgroup]

FROM

bnewstructure:

(qvd);

sunny_talwar

Sure, try it out. I won't be able to offer much unless I have an example to look at. But what you have listed above make sense

matthewp
Creator III
Creator III
Author

I solved this by doing:

bnewstructure:

Mapping LOAD

B_DESC AS [bname],

B_GROUP AS [bgroup]

FROM

bnewstructure:

(qvd);

MAPPING:

MAPPING LOAD * inline [

In, Out

Grouped cos, Grouped companies];

map [Mapped group] using MAPPING;

Details:

load

IF(match([B name],'paul'),'group2',ApplyMap('bnewstructure:',[B name],'Missing')) as [Mapped group],

*;

LOAD

boldstructure.B_DESC as [B name]

FROM

[$(vDetailsQVDDirectory)\boldstructure.qvd]

(qvd);

sunny_talwar

Awesome

I am glad you were able to figure it out all by yourself. This will go a long way in helping you learn faster