Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
@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;
Try this
Flag:
LOAD
id,
primary_id,
1 as Flag
RESIDENT Data
WHERE primary_id = '';
@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;
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.