Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello my dear solver of logic puzzles. Could you help me with something special?
In attachment you'll find file with 3 columns. From these 3 columns you must make table with maximum number in row [Level of parent]. Row [Name] is the name of cell in new table. [Parent] is "parent" cell for [Name]/ And Level is Number of column in our new table for Parent cell.
Have you understood this? Well, I need to make hierarchy. Help .
I got answer.
a:
Load *,
Name as Key;
LOAD Name,
Parent,
Level
FROM
Data.qvd
(qvd);
// Выстроим иерархию
Verdict:
Load Distinct
Max(Level) as TheMostMaxLevel
Resident a;
LET varLevel = 1;
LET varLevelMax = peek('TheMostMaxLevel',0,'Verdict');
LET varLevelDimName = 'Dim' & $(varLevel);
LET varLevelDimNameNext = 'Dim' & ($(#varLevel) + 1);
Aggregation:
LOAD
Name as Key,
Parent as $(varLevelDimName)
Resident a
Where Level = $(#varLevel);
LET varLevel = $(varLevel) + 1;
For i = 2 to $(varLevelMax) step 1
LET varLevelDimName = 'Dim' & $(varLevel);
left Join (Aggregation)
LOAD
Name as Key,
Parent as $(varLevelDimName)
Resident a
Where Level = $(#varLevel);
LET varLevel = $(varLevel) + 1;
NEXT i;
drop Table Verdict;
Stanislaw,
may you provide few rows of input and output table for this input?
regards
D
I got answer.
a:
Load *,
Name as Key;
LOAD Name,
Parent,
Level
FROM
Data.qvd
(qvd);
// Выстроим иерархию
Verdict:
Load Distinct
Max(Level) as TheMostMaxLevel
Resident a;
LET varLevel = 1;
LET varLevelMax = peek('TheMostMaxLevel',0,'Verdict');
LET varLevelDimName = 'Dim' & $(varLevel);
LET varLevelDimNameNext = 'Dim' & ($(#varLevel) + 1);
Aggregation:
LOAD
Name as Key,
Parent as $(varLevelDimName)
Resident a
Where Level = $(#varLevel);
LET varLevel = $(varLevel) + 1;
For i = 2 to $(varLevelMax) step 1
LET varLevelDimName = 'Dim' & $(varLevel);
left Join (Aggregation)
LOAD
Name as Key,
Parent as $(varLevelDimName)
Resident a
Where Level = $(#varLevel);
LET varLevel = $(varLevel) + 1;
NEXT i;
drop Table Verdict;