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: 
a_kosarev
Contributor II
Contributor II

Percentile in pivot table

Hi everyone! 

I'm trying to create a pivot table, with one of the columns showing average of values that a less than the 75th percentile. The rows of the pivot table a different types of work. 

p75.png

 

 

 

If I try to calculate the 75th percentile separately, everything works fine. 

 

=Fractile(Column1, 0.75)

 

 

But if I try to put this formula inside the average formula: 

 

=avg({<Column1 = {"<$(=Fractile(Column1, 0.75))"}>}Column1)

 

 

it calculates percentile of all values, ignoring the division into rows, and therefore the average is not correct. 

Can I somehow make it calculate correct percentile for every kind of work? 

 

upd: 

If I choose one of the rows by clicking on it and thus make a filter apply, p75 avg values change for correct. But if I dissolve the filter and make all rows appear again, it goes back to wrong values.

1 Solution

Accepted Solutions
sunny_talwar

Here you go

If(Dimensionality() = 0, 
Avg({<Completion_Time = {"<$(=Fractile(Completion_Time, 0.75))"}>}Completion_Time), 
Avg(Aggr( If(Completion_Time < Fractile(TOTAL <Work_type> Completion_Time, 0.75), Completion_Time) , Completion_Time, Work_type)))

View solution in original post

9 Replies
Anil_Babu_Samineni

How about this?

=avg({<Column1 = {"='<'&Fractile(Column1, 0.75))"}>}Column1)

 

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
sunny_talwar

Set Analysis is global in nature and is evaluated once per chart instead of once per dimension... try this instead

=Avg(Aggr(
    If(Column1 < Fractile(TOTAL <Division> Column1, 0.75), Column1)
, Column1, Division))

 

a_kosarev
Contributor II
Contributor II
Author

Hi, Talwar

 

thank you very much, now it works fine with the dimensions. 

But now the total row in the pivot table (the bold one at the top) calculates incorrect value. 

Is there any way to get both total and dimensional values correct?  

 

 

sunny_talwar

May be this?

=If(Dimensionality() = 0,
 Avg({<Column1 = {"<$(=Fractile(Column1, 0.75))"}>}Column1),
 Avg(Aggr(
    If(Column1 < Fractile(TOTAL <Division> Column1, 0.75), Column1)
 , Column1, Division))
)

 

a_kosarev
Contributor II
Contributor II
Author

=If(Dimensionality() = 0,
 Avg({<Column1 = {"<$(=Fractile(Column1, 0.75))"}>}Column1),
 Avg(Aggr(
    If(Column1 < Fractile(TOTAL <Division> Column1, 0.75), Column1)
 , Column1, Division))
)

 

This one works just as well with dimensions, but shows nothing in totals (the "-" symbol). 

sunny_talwar

Really, would you be able to share a sample where we can see the issue?

a_kosarev
Contributor II
Contributor II
Author

Here it is

sunny_talwar

Here you go

If(Dimensionality() = 0, 
Avg({<Completion_Time = {"<$(=Fractile(Completion_Time, 0.75))"}>}Completion_Time), 
Avg(Aggr( If(Completion_Time < Fractile(TOTAL <Work_type> Completion_Time, 0.75), Completion_Time) , Completion_Time, Work_type)))
a_kosarev
Contributor II
Contributor II
Author

It work perfectly, thank you for your help!