How to get the percentile value over a dynamic range

Arjun Kamath

New Member
Joined
Jul 4, 2013
Messages
2
Hello,
I have to run the 95th percentile value against a raw data dump from a monitoring tool. The data has multiple devices and each device has about a couple of thousands of samples/values. These values are dynamic, it can be 1000 samples for device 1 and may be 1300 for device 2. The data between 2 devices are separated by an empty row. I need help to run a macro using the percentile formula that can accept a dynamic range in the array so that it should not matter how many samples/values each device has, it should provide the 95 Percentile value.
Current Option: =Percentile(array,value)
What I'm looking for is: =Percentile(A dynamic range starting from a designated cell to all the way till the last cell in that range i.e before the empty row that separate the two devices,value)

Thanks,
Arjun Kamath.
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Welcome to MrExcel.

Examples for column A:

=PERCENTILE(A1:INDEX(A:A,MATCH(TRUE,INDEX(A:A="",),FALSE)-1),0.95)
=PERCENTILE(INDEX(A:A,MATCH(TRUE,INDEX(A:A="",),FALSE)+1):INDEX(A:A,MATCH(9.99999999999999E+307,A:A)),0.95)
 
Upvote 0
Welcome to MrExcel.

Examples for column A:

=PERCENTILE(A1:INDEX(A:A,MATCH(TRUE,INDEX(A:A="",),FALSE)-1),0.95)
=PERCENTILE(INDEX(A:A,MATCH(TRUE,INDEX(A:A="",),FALSE)+1):INDEX(A:A,MATCH(9.99999999999999E+307,A:A)),0.95)

Hello Andrew,

Thanks for the quick help. I have tried both the formulla's and the output is as follows:

=PERCENTILE(A1:INDEX(A:A,MATCH(TRUE,INDEX(A:A="",),FALSE)-1),0.95) => #NUM!
=PERCENTILE(INDEX(A:A,MATCH(TRUE,INDEX(A:A="",),FALSE)+1):INDEX(A:A,MATCH(9.99999999999999E+307,A:A)),0.95)[/QUOTE]=> The output is same as =percentile(A:A,0.95). I have Multiple ranges with different number of rows in each and I need the 95th Percentile value of each range. The ranges are seperated by an empty cell.

I'm not able to attach my spreadsheet in forum, therefore providing a typical senario:

ColumnA ColumnB
Device1
1/1/2013 3
2/1/2013 2
3/1/2013 3
4/1/2013 4

Device2
1/1/2013 6
2/1/2013 7
3/1/2013 9
4/1/2013 5
5/1/2013 11
6/1/2013 45
7/1/2013 5

Device3
1/1/2013 66
2/1/2013 77

I need the 95th Percentile value for each of the range mentioned in the cell next to the device name.

Thanks,
Arjun Kamath.
 
Last edited:
Upvote 0
Example:


Excel 2010
ABCD
1Device1Device13.85
201/01/20133Device234.8
302/01/20132Device376.45
403/01/20133
504/01/20134
6
7Device2
801/01/20136
902/01/20137
1003/01/20139
1104/01/20135
1205/01/201311
1306/01/201345
1407/01/20135
15
16Device3
1701/01/201366
1802/01/201377
Sheet2
Cell Formulas
RangeFormula
D1=PERCENTILE(INDEX(B:B,MATCH(C1,A:A,FALSE)+1):INDEX(INDEX(B:B,MATCH(C1,A:A,FALSE)):B$1000,MATCH(TRUE,INDEX(INDEX(A:A,MATCH(C1,A:A,FALSE)):A$1000="",),FALSE)-1),0.95)
D2=PERCENTILE(INDEX(B:B,MATCH(C2,A:A,FALSE)+1):INDEX(INDEX(B:B,MATCH(C2,A:A,FALSE)):B$1000,MATCH(TRUE,INDEX(INDEX(A:A,MATCH(C2,A:A,FALSE)):A$1000="",),FALSE)-1),0.95)
D3=PERCENTILE(INDEX(B:B,MATCH(C3,A:A,FALSE)+1):INDEX(INDEX(B:B,MATCH(C3,A:A,FALSE)):B$1000,MATCH(TRUE,INDEX(INDEX(A:A,MATCH(C3,A:A,FALSE)):A$1000="",),FALSE)-1),0.95)
 
Upvote 0
Hi Andrew,

I have a similar question as the original post:

I need to find the average base salary distinguished by [Company ID] AND [Position ID]. For example, I need to find what the average base salary is for:
Company ID 1, Position A = $95,000 (($90,000 + $95,000 + $100,000)/3)
Company ID 2, Position A = $105,000 (($100,000 + $105,000 + $110,000)/3)
Company ID 1, Position B = $45,000 (($40,000 + $45,000 + $50,000)/3)
Company ID 2, Position B = $55,000 (($50,000 + $55,000 + $60,000)/3)

I have tried the following formula, but it is limited to only one variable:
{=AVERAGE(IF(Table[Position ID]=A,Table[Base Salary],""))}
{=AVERAGE(IF(Table[Company ID]=1,Table[Base Salary],""))}

I thought I might be able to simply include the "AND(" function to include both variables, but I get an error:
{=AVERAGE(IF(AND(Table[Position ID]=A,Table[Company ID]=1),Table[Base Salary],""))}

Thank you.

[TABLE="class: grid, width: 500, align: center"]
<tbody>[TR]
[TD][Company ID][/TD]
[TD][Position ID][/TD]
[TD][Base Salary][/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]A[/TD]
[TD]$90,000[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]A[/TD]
[TD]$95,000[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]A[/TD]
[TD]$100,000[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]B[/TD]
[TD]$40,000[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]B[/TD]
[TD]$45,000[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]B[/TD]
[TD]$50,000[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]A[/TD]
[TD]$100,000[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]A[/TD]
[TD]$105,000[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]A[/TD]
[TD]$110,000[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]B[/TD]
[TD]$50,000[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]B[/TD]
[TD]$55,000[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]B[/TD]
[TD]$60,000[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
You can't use AND because it returns a single value rather than an array of values. Here are 3 possible formulas:


Excel 2010
ABCDE
1Company IDPosition IDBase Salary95,000
21A90,00095,000
31A95,00095,000
41A100,000
51B40,000
61B45,000
71B50,000
82A100,000
92A105,000
102A110,000
112B50,000
122B55,000
132B60,000
Sheet4
Cell Formulas
RangeFormula
E3=AVERAGEIFS(Table[Base Salary],Table[Company ID],1,Table[Position ID],"A")
E1{=AVERAGE(IF(Table[Company ID]=1,IF(Table[Position ID]="A",Table[Base Salary])))}
E2{=AVERAGE(IF((Table[Company ID]=1)*(Table[Position ID]="A"),Table[Base Salary]))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,286
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top