1

有没有人有经验如何加载/准备数据:

[(1, 'a'), (2, 'b'), (3, 'c'), (4, 'd')]

从 SQL 数据库(作为值存储在那里)获取到 qlik sense 表:

ID,   Value
1,        a
2,        b
3,        v
4,        d
4

1 回答 1

0

查看下面的注释脚本。

执行后,结果表将是:

结果表

set vSQLData = [(1, 'a'), (2, 'b'), (3, 'c'), (4, 'd')];

SQLData:
Load
  // at this point the data will look like: "1, a", "2, b"
  // will split the string on "," and will
  // get the first value as ID
  // and the second one as Valule
  SubField(TempField2, ',', 1) as ID,
  SubField(TempField2, ',', 2) as Value,
;
Load 
  // split the string by ")," and generate N number of rows
  // then for each row remove "(", ")" and "'" characters
  PurgeChar(SubField(TempField1, '),'), '''()''') as TempField2
;
Load
  // remove "[" and "]" characters
  PurgeChar('$(vSQLData)', '[]') as TempField1
AutoGenerate(1)
;
于 2021-10-25T18:01:58.573 回答