PC Review


Reply
Thread Tools Rate Thread

Calculate Percentile By grouping Data in excel

 
 
=?Utf-8?B?TWF4?=
Guest
Posts: n/a
 
      8th Oct 2007
Hi, i am having DATA like this in Excel which will be growing each month, i
would like to calculate
Percentile 50% of sales by grouping data at Month Level, that means for each
month i ll get differnt percentile value , eg. 2007/01 - Percentile Value,
2007/02 another percentile value.... and so on, is it possible to calculate
this way in need VBA

Customer-Month - Sales
X-2007/01-50000
Y-2007/01-75000
Z-2007/01-80000
X-2007/02-50000
Z-2007/02-80000

Thanks


 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      8th Oct 2007
Can you post the worksheet functions you are using. VBA code can do
everything the worksheet function can to and more.....

using the worksheet function
Set CalcRange = Range("B1:B5")
Percentile = worksheetfunction.Percentile(CalcRange,0.5)


From your data it is not clear how to make the Percentile caluclation when
there are more than one data entry for each month.

"Max" wrote:

> Hi, i am having DATA like this in Excel which will be growing each month, i
> would like to calculate
> Percentile 50% of sales by grouping data at Month Level, that means for each
> month i ll get differnt percentile value , eg. 2007/01 - Percentile Value,
> 2007/02 another percentile value.... and so on, is it possible to calculate
> this way in need VBA
>
> Customer-Month - Sales
> X-2007/01-50000
> Y-2007/01-75000
> Z-2007/01-80000
> X-2007/02-50000
> Z-2007/02-80000
>
> Thanks
>
>

 
Reply With Quote
 
=?Utf-8?B?TWF4?=
Guest
Posts: n/a
 
      8th Oct 2007
Hi joel,

i want use worksheet function Percentile, but my problem is the range should
be dynamic, and it should automatically group the rows by some value, in my
case grouping based on Month number, and after that it should return 50th
percentile of the sales figures.

Like for below data, if we calculate manually in excel such as

For Month: 2007/01
=Percentile(A1:A3,0.50) will return - 75000

For Month: 2007/02
=Percentile(A4:A5,0.50) will return - 65000


Cell_Ref-Customer-Month-Sales

A1:X-2007/01-50000
A2:Y-2007/01-75000
A3:Z-2007/01-80000
A4:X-2007/02-50000
A5:Z-2007/02-80000



Thanx


"Joel" wrote:

> Can you post the worksheet functions you are using. VBA code can do
> everything the worksheet function can to and more.....
>
> using the worksheet function
> Set CalcRange = Range("B1:B5")
> Percentile = worksheetfunction.Percentile(CalcRange,0.5)
>
>
> From your data it is not clear how to make the Percentile caluclation when
> there are more than one data entry for each month.
>
> "Max" wrote:
>
> > Hi, i am having DATA like this in Excel which will be growing each month, i
> > would like to calculate
> > Percentile 50% of sales by grouping data at Month Level, that means for each
> > month i ll get differnt percentile value , eg. 2007/01 - Percentile Value,
> > 2007/02 another percentile value.... and so on, is it possible to calculate
> > this way in need VBA
> >
> > Customer-Month - Sales
> > X-2007/01-50000
> > Y-2007/01-75000
> > Z-2007/01-80000
> > X-2007/02-50000
> > Z-2007/02-80000
> >
> > Thanks
> >
> >

 
Reply With Quote
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      8th Oct 2007
Couple of quick questions. The sales quantity need to be in a sperate column
for the Percentile function to work. Should I assume the data is in 3
columns. Column A is x,y,z. Column B is date. Column C is sales quantity.

Also where do you want to put the results? Is the Last Row of the month ok.
I would write a macro that would add the formula into the worksheet, not just
the results. This way if any number is changed the results will
automatically change.

"Max" wrote:

> Hi joel,
>
> i want use worksheet function Percentile, but my problem is the range should
> be dynamic, and it should automatically group the rows by some value, in my
> case grouping based on Month number, and after that it should return 50th
> percentile of the sales figures.
>
> Like for below data, if we calculate manually in excel such as
>
> For Month: 2007/01
> =Percentile(A1:A3,0.50) will return - 75000
>
> For Month: 2007/02
> =Percentile(A4:A5,0.50) will return - 65000
>
>
> Cell_Ref-Customer-Month-Sales
>
> A1:X-2007/01-50000
> A2:Y-2007/01-75000
> A3:Z-2007/01-80000
> A4:X-2007/02-50000
> A5:Z-2007/02-80000
>
>
>
> Thanx
>
>
> "Joel" wrote:
>
> > Can you post the worksheet functions you are using. VBA code can do
> > everything the worksheet function can to and more.....
> >
> > using the worksheet function
> > Set CalcRange = Range("B1:B5")
> > Percentile = worksheetfunction.Percentile(CalcRange,0.5)
> >
> >
> > From your data it is not clear how to make the Percentile caluclation when
> > there are more than one data entry for each month.
> >
> > "Max" wrote:
> >
> > > Hi, i am having DATA like this in Excel which will be growing each month, i
> > > would like to calculate
> > > Percentile 50% of sales by grouping data at Month Level, that means for each
> > > month i ll get differnt percentile value , eg. 2007/01 - Percentile Value,
> > > 2007/02 another percentile value.... and so on, is it possible to calculate
> > > this way in need VBA
> > >
> > > Customer-Month - Sales
> > > X-2007/01-50000
> > > Y-2007/01-75000
> > > Z-2007/01-80000
> > > X-2007/02-50000
> > > Z-2007/02-80000
> > >
> > > Thanks
> > >
> > >

 
Reply With Quote
 
=?Utf-8?B?TWF4?=
Guest
Posts: n/a
 
      9th Oct 2007
Hi joel,

u r right, sales quantity in seperate column, Yes data is in 3 column. Yes
it is perfectly fine if Result is put at the end of row

Thanx for quick reply

"Joel" wrote:

> Couple of quick questions. The sales quantity need to be in a sperate column
> for the Percentile function to work. Should I assume the data is in 3
> columns. Column A is x,y,z. Column B is date. Column C is sales quantity.
>
> Also where do you want to put the results? Is the Last Row of the month ok.
> I would write a macro that would add the formula into the worksheet, not just
> the results. This way if any number is changed the results will
> automatically change.
>
> "Max" wrote:
>
> > Hi joel,
> >
> > i want use worksheet function Percentile, but my problem is the range should
> > be dynamic, and it should automatically group the rows by some value, in my
> > case grouping based on Month number, and after that it should return 50th
> > percentile of the sales figures.
> >
> > Like for below data, if we calculate manually in excel such as
> >
> > For Month: 2007/01
> > =Percentile(A1:A3,0.50) will return - 75000
> >
> > For Month: 2007/02
> > =Percentile(A4:A5,0.50) will return - 65000
> >
> >
> > Cell_Ref-Customer-Month-Sales
> >
> > A1:X-2007/01-50000
> > A2:Y-2007/01-75000
> > A3:Z-2007/01-80000
> > A4:X-2007/02-50000
> > A5:Z-2007/02-80000
> >
> >
> >
> > Thanx
> >
> >
> > "Joel" wrote:
> >
> > > Can you post the worksheet functions you are using. VBA code can do
> > > everything the worksheet function can to and more.....
> > >
> > > using the worksheet function
> > > Set CalcRange = Range("B1:B5")
> > > Percentile = worksheetfunction.Percentile(CalcRange,0.5)
> > >
> > >
> > > From your data it is not clear how to make the Percentile caluclation when
> > > there are more than one data entry for each month.
> > >
> > > "Max" wrote:
> > >
> > > > Hi, i am having DATA like this in Excel which will be growing each month, i
> > > > would like to calculate
> > > > Percentile 50% of sales by grouping data at Month Level, that means for each
> > > > month i ll get differnt percentile value , eg. 2007/01 - Percentile Value,
> > > > 2007/02 another percentile value.... and so on, is it possible to calculate
> > > > this way in need VBA
> > > >
> > > > Customer-Month - Sales
> > > > X-2007/01-50000
> > > > Y-2007/01-75000
> > > > Z-2007/01-80000
> > > > X-2007/02-50000
> > > > Z-2007/02-80000
> > > >
> > > > Thanks
> > > >
> > > >

 
Reply With Quote
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      9th Oct 2007
The code check dates in column B. If the date in a row does not match the
date in the nex row the code adds the Percentile formula in column d. The
percentile formuila uses the Sales figures in Column C. FirstRow is changed
everytime a new date is found so a Range (row number) of cells can be
inserted into the Percentile formula. CalcRange is a string that represents
the range of cells C1:C3. PercentFormula is another string which is simply
the formula that gets added into the worksheet =PERCENTILE(C1:C3,0.5)

Actually looking at the code is easier to understand than my written
explanation.

Sub calc_percentile()

FirstRow = 1
RowCount = 1
Do While Cells(RowCount, "A") <> ""
If Cells(RowCount, "B") <> _
Cells(RowCount + 1, "B") Then

CalcRange = _
"C" & FirstRow & ":C" & RowCount

PercentFormula = _
"=Percentile(" & CalcRange & ",0.5)"
Cells(RowCount, "D").Formula = PercentFormula
FirstRow = RowCount + 1
End If
RowCount = RowCount + 1
Loop
End Sub


"Max" wrote:

> Hi joel,
>
> u r right, sales quantity in seperate column, Yes data is in 3 column. Yes
> it is perfectly fine if Result is put at the end of row
>
> Thanx for quick reply
>
> "Joel" wrote:
>
> > Couple of quick questions. The sales quantity need to be in a sperate column
> > for the Percentile function to work. Should I assume the data is in 3
> > columns. Column A is x,y,z. Column B is date. Column C is sales quantity.
> >
> > Also where do you want to put the results? Is the Last Row of the month ok.
> > I would write a macro that would add the formula into the worksheet, not just
> > the results. This way if any number is changed the results will
> > automatically change.
> >
> > "Max" wrote:
> >
> > > Hi joel,
> > >
> > > i want use worksheet function Percentile, but my problem is the range should
> > > be dynamic, and it should automatically group the rows by some value, in my
> > > case grouping based on Month number, and after that it should return 50th
> > > percentile of the sales figures.
> > >
> > > Like for below data, if we calculate manually in excel such as
> > >
> > > For Month: 2007/01
> > > =Percentile(A1:A3,0.50) will return - 75000
> > >
> > > For Month: 2007/02
> > > =Percentile(A4:A5,0.50) will return - 65000
> > >
> > >
> > > Cell_Ref-Customer-Month-Sales
> > >
> > > A1:X-2007/01-50000
> > > A2:Y-2007/01-75000
> > > A3:Z-2007/01-80000
> > > A4:X-2007/02-50000
> > > A5:Z-2007/02-80000
> > >
> > >
> > >
> > > Thanx
> > >
> > >
> > > "Joel" wrote:
> > >
> > > > Can you post the worksheet functions you are using. VBA code can do
> > > > everything the worksheet function can to and more.....
> > > >
> > > > using the worksheet function
> > > > Set CalcRange = Range("B1:B5")
> > > > Percentile = worksheetfunction.Percentile(CalcRange,0.5)
> > > >
> > > >
> > > > From your data it is not clear how to make the Percentile caluclation when
> > > > there are more than one data entry for each month.
> > > >
> > > > "Max" wrote:
> > > >
> > > > > Hi, i am having DATA like this in Excel which will be growing each month, i
> > > > > would like to calculate
> > > > > Percentile 50% of sales by grouping data at Month Level, that means for each
> > > > > month i ll get differnt percentile value , eg. 2007/01 - Percentile Value,
> > > > > 2007/02 another percentile value.... and so on, is it possible to calculate
> > > > > this way in need VBA
> > > > >
> > > > > Customer-Month - Sales
> > > > > X-2007/01-50000
> > > > > Y-2007/01-75000
> > > > > Z-2007/01-80000
> > > > > X-2007/02-50000
> > > > > Z-2007/02-80000
> > > > >
> > > > > Thanks
> > > > >
> > > > >

 
Reply With Quote
 
=?Utf-8?B?TWF4?=
Guest
Posts: n/a
 
      9th Oct 2007
Hi Joel, Thanx for the solution, ill chek it. :-)

"Joel" wrote:

> The code check dates in column B. If the date in a row does not match the
> date in the nex row the code adds the Percentile formula in column d. The
> percentile formuila uses the Sales figures in Column C. FirstRow is changed
> everytime a new date is found so a Range (row number) of cells can be
> inserted into the Percentile formula. CalcRange is a string that represents
> the range of cells C1:C3. PercentFormula is another string which is simply
> the formula that gets added into the worksheet =PERCENTILE(C1:C3,0.5)
>
> Actually looking at the code is easier to understand than my written
> explanation.
>
> Sub calc_percentile()
>
> FirstRow = 1
> RowCount = 1
> Do While Cells(RowCount, "A") <> ""
> If Cells(RowCount, "B") <> _
> Cells(RowCount + 1, "B") Then
>
> CalcRange = _
> "C" & FirstRow & ":C" & RowCount
>
> PercentFormula = _
> "=Percentile(" & CalcRange & ",0.5)"
> Cells(RowCount, "D").Formula = PercentFormula
> FirstRow = RowCount + 1
> End If
> RowCount = RowCount + 1
> Loop
> End Sub
>
>
> "Max" wrote:
>
> > Hi joel,
> >
> > u r right, sales quantity in seperate column, Yes data is in 3 column. Yes
> > it is perfectly fine if Result is put at the end of row
> >
> > Thanx for quick reply
> >
> > "Joel" wrote:
> >
> > > Couple of quick questions. The sales quantity need to be in a sperate column
> > > for the Percentile function to work. Should I assume the data is in 3
> > > columns. Column A is x,y,z. Column B is date. Column C is sales quantity.
> > >
> > > Also where do you want to put the results? Is the Last Row of the month ok.
> > > I would write a macro that would add the formula into the worksheet, not just
> > > the results. This way if any number is changed the results will
> > > automatically change.
> > >
> > > "Max" wrote:
> > >
> > > > Hi joel,
> > > >
> > > > i want use worksheet function Percentile, but my problem is the range should
> > > > be dynamic, and it should automatically group the rows by some value, in my
> > > > case grouping based on Month number, and after that it should return 50th
> > > > percentile of the sales figures.
> > > >
> > > > Like for below data, if we calculate manually in excel such as
> > > >
> > > > For Month: 2007/01
> > > > =Percentile(A1:A3,0.50) will return - 75000
> > > >
> > > > For Month: 2007/02
> > > > =Percentile(A4:A5,0.50) will return - 65000
> > > >
> > > >
> > > > Cell_Ref-Customer-Month-Sales
> > > >
> > > > A1:X-2007/01-50000
> > > > A2:Y-2007/01-75000
> > > > A3:Z-2007/01-80000
> > > > A4:X-2007/02-50000
> > > > A5:Z-2007/02-80000
> > > >
> > > >
> > > >
> > > > Thanx
> > > >
> > > >
> > > > "Joel" wrote:
> > > >
> > > > > Can you post the worksheet functions you are using. VBA code can do
> > > > > everything the worksheet function can to and more.....
> > > > >
> > > > > using the worksheet function
> > > > > Set CalcRange = Range("B1:B5")
> > > > > Percentile = worksheetfunction.Percentile(CalcRange,0.5)
> > > > >
> > > > >
> > > > > From your data it is not clear how to make the Percentile caluclation when
> > > > > there are more than one data entry for each month.
> > > > >
> > > > > "Max" wrote:
> > > > >
> > > > > > Hi, i am having DATA like this in Excel which will be growing each month, i
> > > > > > would like to calculate
> > > > > > Percentile 50% of sales by grouping data at Month Level, that means for each
> > > > > > month i ll get differnt percentile value , eg. 2007/01 - Percentile Value,
> > > > > > 2007/02 another percentile value.... and so on, is it possible to calculate
> > > > > > this way in need VBA
> > > > > >
> > > > > > Customer-Month - Sales
> > > > > > X-2007/01-50000
> > > > > > Y-2007/01-75000
> > > > > > Z-2007/01-80000
> > > > > > X-2007/02-50000
> > > > > > Z-2007/02-80000
> > > > > >
> > > > > > Thanks
> > > > > >
> > > > > >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculate Percentile by grouping fields in Database =?Utf-8?B?TWF4?= Microsoft Access VBA Modules 4 10th Oct 2007 02:19 PM
Use excel to calculate a percentile from data in multiple sheets =?Utf-8?B?RW15Rw==?= Microsoft Excel Worksheet Functions 0 24th Jul 2007 03:40 AM
I need to calculate Percentile or Quantile in Access =?Utf-8?B?aGFycnkubWFydGluQGdlLmNvbQ==?= Microsoft Access VBA Modules 2 27th Feb 2007 08:52 PM
calculate percentile in access =?Utf-8?B?RWxlYW5vciBvZiBBcXVpdGFpbmU=?= Microsoft Access Queries 1 2nd May 2006 12:35 PM
How do I calculate percentile in acccess? =?Utf-8?B?Y2hpYmJ5IHJhY2Vy?= Microsoft Access Queries 2 25th Feb 2005 01:03 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:39 PM.