Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
April 13–15 - Dare to Unleash a New Professional You at Qlik Connect 2026: Register Now!
cancel
Showing results for 
Search instead for 
Did you mean: 
orangebloss
Creator
Creator

Allocate value from Hierarchy level to a lower lever

HI

 

I've created a hierarchy based on Task ID

 

Hierarchy ( TaskId,TaskParentTaskId,TaskName,'ParentTask')

 

On the first level of the hierarchy there is an additional field that I could do with pulling down to all levels below it :

if(TagName = 'CME','CME',

if (TagName ='NPD', 'NPD',

if (TagName='Non-Contract Specific','Non-Contract Specific',''))) as ProjectType_TAG,

if(TagName = 'UK','UK',
if (TagName ='APAC', 'APAC',
if (TagName='RoW','RoW',
if (TagName ='Americas', 'Americas')))) as Region_TAG

 

This tag only appears on the 'parent' of the hierarchy (essentially I'm pulling through a task list - all the subtasks should have the same data but the source does not contain that). The TagName contains several key words so I'm only looking for specific ones.

In the example below anything with an xxx should contain the same data as the related TaskName e.g. Subtask1 should have the same Region_TAG as TaskName1 - is this even possible? At the moment I'm losing data in my charts if I try to filter on Region/project type tags which is understandable but I want both!

 

Task ProjectType_TAG Region_TAG
TaskName1 CME UK
Subtask1 xxx xxx
Subtask1.2 xxx xxx
TaskName2 NPD RoW
Subtask2 xxx xxx
Subtask2.1 xxx xxx
Labels (1)
6 Replies
F_B
Specialist II
Specialist II

Hi @orangebloss ,

could this be what you are looking for?

RawData:
LOAD
TaskId,
TaskParentTaskId,
TaskName,
if(TagName = 'CME','CME',
if (TagName ='NPD', 'NPD',
if (TagName='Non-Contract Specific','Non-Contract Specific',''))) as ProjectType_TAG,
if(TagName = 'UK','UK',
if (TagName ='APAC', 'APAC',
if (TagName='RoW','RoW',
if (TagName ='Americas', 'Americas')))) as Region_TAG
FROM [YourDataSource];

//Create the hierarchy
HierarchyTable:
Hierarchy(TaskId, TaskParentTaskId, TaskName, ParentTaskId, ParentTaskName, Path, Depth)
LOAD
TaskId,
TaskParentTaskId,
TaskName
RESIDENT RawData;

//Create mapping tables for ProjectType_TAG and Region_TAG
ProjectTypeMap:
MAPPING LOAD
TaskId,
ProjectType_TAG
RESIDENT RawData
WHERE len(ProjectType_TAG) > 0;

RegionMap:
MAPPING LOAD
TaskId,
Region_TAG
RESIDENT RawData
WHERE len(Region_TAG) > 0;

//Apply the mappings to propagate the tags down the hierarchy
FinalTable:
LOAD
TaskId,
TaskParentTaskId,
TaskName,
ApplyMap('ProjectTypeMap', HierarchyBelongsTo(TaskId, ParentTaskId), '') as ProjectType_TAG,
ApplyMap('RegionMap', HierarchyBelongsTo(TaskId, ParentTaskId), '') as Region_TAG
RESIDENT HierarchyTable;

// Drop intermediate tables
DROP TABLE RawData;
DROP TABLE HierarchyTable;

orangebloss
Creator
Creator
Author

Hi, Apologies I'd missed your response I'll see if I can make this work and feed back!

orangebloss
Creator
Creator
Author

I'm having a little trouble with the final table? I'm not sure why the red?

 

orangebloss_0-1727098770152.png

 

F_B
Specialist II
Specialist II

No worries

F_B
Specialist II
Specialist II

I'll look into it to see what's going on

F_B
Specialist II
Specialist II

Meanwhile, you should achieve your goal also avoiding HierarchyBelongsTo, try like this:

 

FinalTable:
LOAD
TaskId,
TaskParentTaskId,
TaskName,
ApplyMap('ProjectTypeMap', TaskParentTaskId,
ApplyMap('ProjectTypeMap', TaskId, '')) as ProjectType_TAG,
ApplyMap('RegionMap', TaskParentTaskId,
ApplyMap('RegionMap', TaskId, '')) as Region_TAG
RESIDENT HierarchyTable;