根据qlikview

时间:2016-04-28 11:07:50

标签: qlikview

我是Qlikview的新手。

我需要获得Goodpages列的平均值,在第一个值范围之间为0(在第3行中找到),最后值为0(在第10行中找到) 。注意:数据不是静态的。因此,列(黄色计算)中的值0可以出现在任何行中。我需要这个要求。

GoodPages   YellowCalculated
315         0.35
320         0.25
300         0      --  First Value as 0 found  in 3rd row
200         0.37
250         0.17
315         0.18
350         0
345        0.68
355        0.57
325        0  -- Last Value as 0 found in 10th row
275        0.27

1 个答案:

答案 0 :(得分:0)

不确定要如何呈现结果。这是一种方式。

创建一个包含尺寸ID和GoodPages的直表。您将获得此表达式的平均值:avg( {<_flag_avg = {1}>} GoodPages)。总平均值将显示您所追求的内容。您还可以添加另一个表达式:only(YellowCalculated)

//Script:
Data:
Load 
    RowNo() as ID,
    *,
    if(YellowCalculated = 0,1) as _flag_zero
;

LOAD * INLINE [
GoodPages, YellowCalculated
315,0.35
320,0.25
300,0
200,0.37
250,0.17
315,0.18
350,0
345,0.68
355,0.57
325,0 
275,0.27
];

minmax:
load
    min(ID) as minRow,
    max(ID) as maxrow
Resident Data
where _flag_zero = 1;

test:
IntervalMatch(ID)
Load
    minRow,
    maxrow
Resident minmax;

LEFT JOIN(Data)
LOAD 
    ID,
    1 as _flag_avg
Resident test;

drop table test;
drop table minmax;
drop field _flag_zero;
相关问题