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: 
Not applicable

Average the top 95percentile only

Hello

If any one can help me with the below screen shot.

1. Need to find the 95th percentile of the orders

2.need to avg or sum those orders in red

Image.png

in the above table I need to calculate the 95th percentile of the orders sorted and then calculate the average or Sum of those number which is in red.

Please help

Regards

A

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Maybe something like

Avg(Aggr( If(Rank(-Sum(NbOrders))< 0.95*Count(DISTINCT TOTAL CalcHour), Sum(NbOrders)), CalcDate, CalcHour))

CalcDate MetricName CalcHour Sum(NbOrders) Num(Rank(-Sum(NbOrders),0,4)) Avg(Aggr( If(Rank(-Sum(NbOrders))< 0.95*Count(DISTINCT TOTAL CalcHour), Sum(NbOrders)), CalcDate, CalcHour))
1554 52
08/20/2017Stock22313
08/20/2017Stock8626
08/20/2017Stock5838
08/20/2017Stock19838
08/20/2017Stock714514
08/20/2017Stock2321621
08/20/2017Stock923723
08/20/2017Stock2127827
08/20/2017Stock1028928
08/20/2017Stock6321032
08/20/2017Stock11361136
08/20/2017Stock12371237
08/20/2017Stock18461346
08/20/2017Stock15531453
08/20/2017Stock4701570
08/20/2017Stock17771677
08/20/2017Stock13831783
08/20/2017Stock20861886
08/20/2017Stock210019100
08/20/2017Stock1611320113
08/20/2017Stock313021130
08/20/2017Stock1414322143
08/20/2017Stock118623 
08/20/2017Stock022424

View solution in original post

10 Replies
Anil_Babu_Samineni

Provide sample work file?

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Kushal_Chawda

try

=avg(total aggr(Fractile(total Value,0.95),CalcDate,MetricName)

ankur_abhishek
Contributor III
Contributor III

Hi Arjun

You can use Fractile() function calculate 95 percentile 

fractile(TOTAL aggr(Sum(Field name ),Field_Name_1), 0.95)


Thanks

Ankur

Not applicable
Author

Anil I have attached the File to this chain

Not applicable
Author

Hello kushal

Thanks for replying

I tried with your formula but I am unable to get it working

Attached the file

Not applicable
Author

Attached the file,

1.I have to sum the orders

2.I have sort the orders by rank by ascending order

3.then find the 95th percentile  and average the those top 95 percentile

thanks for reply with the formula, I tried with that but I am unable to get it work

Not applicable
Author

Hello Ankur

I  tried with your formula too, still I am not able to get it work

swuehl
MVP
MVP

Maybe something like

Avg(Aggr( If(Rank(-Sum(NbOrders))< 0.95*Count(DISTINCT TOTAL CalcHour), Sum(NbOrders)), CalcDate, CalcHour))

CalcDate MetricName CalcHour Sum(NbOrders) Num(Rank(-Sum(NbOrders),0,4)) Avg(Aggr( If(Rank(-Sum(NbOrders))< 0.95*Count(DISTINCT TOTAL CalcHour), Sum(NbOrders)), CalcDate, CalcHour))
1554 52
08/20/2017Stock22313
08/20/2017Stock8626
08/20/2017Stock5838
08/20/2017Stock19838
08/20/2017Stock714514
08/20/2017Stock2321621
08/20/2017Stock923723
08/20/2017Stock2127827
08/20/2017Stock1028928
08/20/2017Stock6321032
08/20/2017Stock11361136
08/20/2017Stock12371237
08/20/2017Stock18461346
08/20/2017Stock15531453
08/20/2017Stock4701570
08/20/2017Stock17771677
08/20/2017Stock13831783
08/20/2017Stock20861886
08/20/2017Stock210019100
08/20/2017Stock1611320113
08/20/2017Stock313021130
08/20/2017Stock1414322143
08/20/2017Stock118623 
08/20/2017Stock022424
Not applicable
Author

Hello Stefan,

This works for me to find the 95th percentile and average of that as you have done, but it changes when i remove the selections.

Ideally I want the table to be like this

Capture.PNG

with or without selections I should have the same result as above