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

Override Hierarchy

Hi Guys,

I have 3 tables Fact, Dim1, Dim2.

Fact table contains BCode,Pcode,Amount

Dim1 contains BCode,Unit

Dim2 contains PCode,Region,Country

My requirement is if i select Unit = Unit2 and Country = Thailand then my actual Region = Asia

But as per my req i need to show if i select Unit = Unit2 and Country = Thailand then Region = China

I am attaching sample QVW also. Could you please somebody help me here?

Thanks,

Chiru

1 Solution

Accepted Solutions
ramoncova06
Specialist III
Specialist III

I think Brad is right and you need to do a mapping, the example you provided is a little limited, but something like this should work

mapping

OverrideChinaMapping:

load

'Asia_Thailand' as Key,

'China' as Region

AutoGenerate(1);

Fact:

LOAD * Inline [

BCode,PCode,Amount

B1,P1,10

B2,P1,11

B3,P2,10

B4,P2,15

B5,P3,20

B6,P3,10

B7,P4,22

B7,P4,33

];

Dim1:

LOAD * Inline [

BCode,Unit

B1,Unit1

B2,Unit1

B3,Unit2

B4,Unit2

B5,Unit3

B6,Unit3

B7,Unit4

B8,Unit4

];

Dim2:

load

PCode,

ApplyMap('OverrideChinaMapping',Region&'_'&Country,Region) as Region,

Country;

LOAD * Inline [

PCode,Region,Country

P1,Asia,India

P2,Asia,Thailand

P3,China,China

P4,Europe,England

];

View solution in original post

7 Replies
settu_periasamy
Master III
Master III

Hi,

Hope you know, if there is related data in your source, it data will show automatically.

In your table, the country data 'Thailand' not related with Region 'China'.

is there any logic to get the data?

Capture.JPG

Not applicable
Author

Hi Periasamy,

Actually my requirement is i need to map if Unit = Unit2 and Country = Thailand then Region to China.

I tried using some joins in script level but didn't get exact required output.


Thanks,

Chiru

Not applicable
Author

Chiranjeevi,

You need to create 2 Mapping tables 1 for Unit & 1 for Region & when using apply map, if your unit map is satisfied apply region map inside it.

like, applymap(Unit,applymap(Region),'None').

Thanks

Brad.

Not applicable
Author

Hi Bharadwaaj,

Could you please give sample QVW.

It's my request to you. Hope you will accept it.

Thanks,

Chiru

ramoncova06
Specialist III
Specialist III

I think Brad is right and you need to do a mapping, the example you provided is a little limited, but something like this should work

mapping

OverrideChinaMapping:

load

'Asia_Thailand' as Key,

'China' as Region

AutoGenerate(1);

Fact:

LOAD * Inline [

BCode,PCode,Amount

B1,P1,10

B2,P1,11

B3,P2,10

B4,P2,15

B5,P3,20

B6,P3,10

B7,P4,22

B7,P4,33

];

Dim1:

LOAD * Inline [

BCode,Unit

B1,Unit1

B2,Unit1

B3,Unit2

B4,Unit2

B5,Unit3

B6,Unit3

B7,Unit4

B8,Unit4

];

Dim2:

load

PCode,

ApplyMap('OverrideChinaMapping',Region&'_'&Country,Region) as Region,

Country;

LOAD * Inline [

PCode,Region,Country

P1,Asia,India

P2,Asia,Thailand

P3,China,China

P4,Europe,England

];

Not applicable
Author

Thanks Ramon,

Chiranjeevi, Check out Ramon's reply. He explained it pretty good & a sample QVW always helps if you can provide.

Thanks

Brad.

Not applicable
Author

Chiranjeevi,

here is a sample qvw based on above script.

Thanks

Brad.