Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Averages: Remove top and bottom 10%

I have the below script that calculates the averages of business days and calendar days. The problem, I have outlier values that are skewing results.

Can I:

Remove top 10% from the average?

Remove top 10% and bottom 10% from the average?

LOAD

D AS CONTACT_D,
Avg([FIRST_CONTACT_CAL_DAYS])AS Avg_FirstPhoneContact_Days,
Avg([FIRST_CONTACT_WK_DAYS])AS Avg_FIRST_CONTACT_WK_DAYS

FROM $(vPath_QVDs)MainTable.qvd(qvd)

Where 1=1
AND NOT IsNull(FIRST_CONTACT_CAL_DAYS)
AND NOT IsNull(FIRST_CONTACT_WK_DAYS)
AND START_DT > Addmonths(today(),-12)

GROUP BY
D

13 Replies
Anonymous
Not applicable
Author

CORRECT

sunny_talwar

Try this

Avg(Aggr(If(FIRST_CONTACT_CAL_DAYS >= Fractile(TOTAL <PROGRAM> FIRST_CONTACT_CAL_DAYS, 0.10) AND FIRST_CONTACT_CAL_DAYS <= Fractile(TOTAL <PROGRAM> FIRST_CONTACT_CAL_DAYS, 0.90), FIRST_CONTACT_CAL_DAYS), PROGRAM, id))

Capture.PNG

Anonymous
Not applicable
Author

I need to add another filter in the expression.

Something like below:

ASSIGNED_STATUS = 'NEWLY ASSIGNED MEMBER'

Can I easily add that into the expression?

sunny_talwar

Should be simple

Avg({<ASSIGNED_STATUS = {'NEWLY ASSIGNED MEMBER'}>} Aggr(

If(Only({<ASSIGNED_STATUS = {'NEWLY ASSIGNED MEMBER'}>} FIRST_CONTACT_CAL_DAYS) >=

Fractile({<ASSIGNED_STATUS = {'NEWLY ASSIGNED MEMBER'}>} TOTAL <PROGRAM> FIRST_CONTACT_CAL_DAYS, 0.10) AND

Only({<ASSIGNED_STATUS = {'NEWLY ASSIGNED MEMBER'}>} FIRST_CONTACT_CAL_DAYS) <=

Fractile({<ASSIGNED_STATUS = {'NEWLY ASSIGNED MEMBER'}>}TOTAL <PROGRAM> FIRST_CONTACT_CAL_DAYS, 0.90),

FIRST_CONTACT_CAL_DAYS), PROGRAM, id))