Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now

Trimean In Qlikview

cancel
Showing results for 
Search instead for 
Did you mean: 
Taoufiq_Zarra

Trimean In Qlikview

Last Update:

Sep 21, 2022 1:07:35 PM

Updated By:

Sue_Macaluso

Created date:

Jul 2, 2020 9:21:16 AM

Trimean : Mean, excluding outlier

Hi,

Recently I helped a community member to calculate the Trimean, I found this indicator interesting, so I decided to share it here as well.

The trimean (TM), or Tukey's trimean, is a measure of a probability distribution's location defined as a weighted average of the distribution's median and its two quartiles: (1)

Capture.PNG

trimean calculates the mean taken by excluding a percentage of data points from the top and bottom tails of a data set. You can use this function when you wish to exclude outlying data from your analysis (2)

Example :

for the following example :TRIMMEAN is 3.778

LOAD * INLINE [
    Data
    4
    5
    6
    7
    2
    3
    4
    5
    1
    2
    3
];

 

To calculate Trimean on Qlikview, we will take the example below :

DATECLAIM PAID
02/01/2020250
05/01/2020750
08/01/202025000
11/01/202050000
14/01/202075000
17/01/20202500
20/01/20203500
23/01/2020500000
26/01/2020850000
29/01/202025000
01/02/202010000
04/02/20201800000
07/02/202050000
10/02/202065000
13/02/202045000
16/02/20201500000
19/02/2020450000
22/02/202018500
25/02/202025000
28/02/202050000
02/03/202075000

 

the expected output is :

Normal Average         267 643
Trimmean         201 066

 

the script can be presented as :

Data0:
LOAD 
	 DATE, 
     [CLAIM PAID]
    
FROM
[.\TRIMMEAN(1).xlsx]
(ooxml, embedded labels, table is Sheet1);

Data:
noconcatenate
LOAD rowno() as IDtmp,
	 DATE, 
     [CLAIM PAID]
    
resident Data0 order by [CLAIM PAID];
drop table Data0;

let percent=0.1;

Tmp1:

load count([CLAIM PAID]) as CountClaim resident Data;

let vcount=peek('CountClaim',0,'tmp');

drop table Tmp1;

let k=floor($(vcount)*($(percent))/2);

Tmp2:
load min(IDtmp) as minIDtmp, max(IDtmp) as maxIDtmp resident Data;


let Idmin=peek('minIDtmp',0,'Tmp2')+$(k);
let Idmax=peek('maxIDtmp',0,'Tmp2')-$(k);

drop table Tmp2;

 

output :

Capture.PNG

 

 

Tags (1)
Version history
Last update:
‎2022-09-21 01:07 PM
Updated by: