我有一个以下结构的数据集:
Company.ID DDR (25632) PTL (89567)
2512 89 74
9875 78 96
7892 14 73
我想将标题分成两行。换句话说,标题的第二部分应该或可能是第一个变量。如何将数据集转换为所需的形式(见下文):
Company.ID DDR PTL
- (25632) (89567)
2512 89 74
9875 78 96
7892 14 73
要在Qlik中复制上面的示例,请运行以下代码:
LOAD * Inline [
[Company.ID], [DDR (25632)], [PTL (89567)]
2512,89,74
9875,78,96
7892,14,73
];
任何帮助或tipp将非常感谢!
您需要循环列,重命名它们并使用新值进行连接。这是我写的例子:
table:
LOAD * Inline [
Company.ID, DDR (25632), PTL (89567)
2512,89,74
9875,78,96
7892,14,73
];
For i=1 to NoOfFields('table')
LET vField = FieldName($(i),'table');
LET vFieldName_$(i) = SubField('$(vField)',' ',1);
LET vFieldValue_$(i) = SubField('$(vField)',' ',2);
If '$(vField)' <> '$(vFieldName_$(i))' THEN
Rename Field '$(vField)' TO '$(vFieldName_$(i))';
EndIf
next
Concatenate(table)
Load * Inline [
'$(vFieldName_1)', '$(vFieldName_2)', '$(vFieldName_3)'
'$(vFieldValue_1)', '$(vFieldValue_2)', '$(vFieldValue_3)'
];