Qlik感知脚本中的变量

时间:2016-04-20 03:12:34

标签: variables scripting qliksense

我正在尝试根据表格中的条件总数来计算评分阈值。但由于某种原因,我无法获得变量的价值。我尝试了Qliksense手册中的每种语法组合。能否帮助我如何通过评估每个变量的表达式并描述评级映射表来获取评级映射表中的实际数字?

[Data Structure]:
LOAD [Resource],
    [Criteria],
    [Sub-Criteria],
    [Weight],
    [Value],
([Weight]*[Value]) As [Score]
FROM [lib://econtent dashboard/Final weighted criteria 7-20-15.xlsm]
(ooxml, embedded labels, table is [Data Structure]);


LET vNumberofCriteria=$(=Count(distinct [Criteria]));
LET vThresholds=$(=vNumberofCriteria*100);
LET vTr1=$(#vThresholds);
LET vTr2=$(=2*$(#vTr1));
LET vTr3=$(=3*$(#vTr1));
LET vTr4=$(=4*$(#vTr1));
LET vTr5=$(=5*$(#vTr1));


[Rating Mapping]:
 Load * INLINE [
    Treshhold, Rating, Image Location
    0, NA, http://localhost:4848/content/default/notavailable.png
    $(#vTr1), Unsatisfactory,   http://localhost:4848/content/default/unsatisfactory.png
    $(#vTr2), Marginal, http://localhost:4848/content/default/marginal.png
    $(#vTr3), Good, http://localhost:4848/content/default/good.png
    $(#vTr4), Satisfactory, http://localhost:4848/content/default/satisfactory.png
    $(#vTr5), Superior, http://localhost:4848/content/default/superior.png
];

由于

1 个答案:

答案 0 :(得分:0)

你不能以这种方式对变量求和,因为它不知道你正在看哪个表。

您可以创建一个临时表来进行聚合,然后使用peek将其分配给您的变量。

[DataStructureCount]:
LOAD
Count(distinct [Criteria]) as CriteriaCount
RESIDENT [Data Structure];

Let vNumberofCriteria= peek('CriteriaCount',0,'DataStructureCount');

DROP TABLE DataStructureCount;