2016-04-28 56 views
0

中Column2的第一個值(0)和最後一個值(0)之間的範圍獲得第一列的平均值我對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 

回答

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; 
+0

謝謝mickeger。它當然會幫助我。我只想顯示價值。所以我創建了文本框並使用了你給出的平均標誌。我得到了我正在尋找的價值。 – Harish

+0

@Harish尼斯:)請標記答案是正確的,如果這有助於你。 – mickeger