Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
CasperQlik
Creator
Creator

Flag Logic Help

I have a data structure that looks something like this:

id primary_id
1 4
2 7
3 4
4  
5 4
6 7
7 4
8 7
9  
10  

 

Nodes have an ID an can point to a primary (parent) node. Some nodes have no primary and have no nods pointing to them.

I need to create a flag dimension that marks any row that either has a primary node or is a primary node for a "child" node. In other words, all the connected nodes need to be marked.

I can't quite figure out the logic and any help is appreciated.

1 Solution

Accepted Solutions
Kushal_Chawda

@CasperQlik  If I understood correctly. try below

Data:
LOAD ID,
     PRIMARY_ID
FROM table;

left join(Data)
LOAD distinct PRIMARY_ID as ID
              1 as Flag
resident Data;

View solution in original post

3 Replies
Chanty4u
MVP
MVP

Try this 

 

Flag:

LOAD

    id,

    primary_id,

    1 as Flag

RESIDENT Data

WHERE primary_id = '';

 

 

   

Kushal_Chawda

@CasperQlik  If I understood correctly. try below

Data:
LOAD ID,
     PRIMARY_ID
FROM table;

left join(Data)
LOAD distinct PRIMARY_ID as ID
              1 as Flag
resident Data;
CasperQlik
Creator
Creator
Author

It almost does the trick.
The logic only flags any Node that is a parent but I would like a flag for both parent nodes and child notes in one field.

However, I have marked it as the solution since I used your logic to solve my issue.

Thanks.