473,480 Members | 3,796 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Percetile bucketing

4 New Member
I have found this page

http://bytes.com/topic/access/answer...rcentile-usage

I have the percentile function working but instead of calculating a percentile for each bucket it is calculating if for the whole data set.I need it per bucket. Any help is greatly appreciated

Expand|Select|Wrap|Line Numbers
  1. Name    Days
  2. bob    5
  3. bob    3
  4. bob    3
  5. bob    56
  6. bob    76
  7. bob    3
  8. bob    56
  9. bob    8
  10. bob    7
  11. jake    34
  12. jake    3
  13. jake    2
  14. jake    6
  15. jake    8
  16. jake    12
  17. jake    32
  18. jake    7
  19. ted    87
  20. ted    9
  21. ted    3
  22. ted    12
  23. ted    12
  24. ted    3
  25. ted    5
  26. walt    45
  27. walt    8
  28. walt    67
  29. walt    67
  30. walt    97
  31. walt    23
  32. walt    41
  33. walt    45
  34. walt    12
  35. walt    12
  36. walt    15
  37. walt    16
  38.  
Sorry for the spelling error. I am unable to change the title.
Jun 21 '10 #1
5 1949
FishVal
2,653 Recognized Expert Specialist
fCalculatePercentiles() function written by ADezii takes all records from the table. You need to modify it in such a way that it filters only relevant records. It is not that difficult. Please post what you've tried yourself so far and you will certainly get help on where you've messed.

Kind regards,
Fish
Jun 22 '10 #2
agentmcmillan
4 New Member
@FishVal
The Challenge I am running into is that I don’t know where to start. Access may be a 2nd nature to you, but I am very new and frustrated with the software. I typically only work in excel. The table I posted is a very low level example of what I am doing. I am looking at a phone center that in within my department and trying to derive our 90th percentile of call times for the call types we receive. The VBA module that is used it out of my skill set. I greatly appreciate any help you can give me.

Thanks again
AgentMcMillan
Jun 22 '10 #3
FishVal
2,653 Recognized Expert Specialist
@agentmcmillan
You need to pass an additional argument to fCalculatePercentiles() - a value of [bucket] field to filter the table records by. fCalculatePercentiles() code should filter relevant records when opening recordset.
Jun 23 '10 #4
agentmcmillan
4 New Member
@FishVal
are you saying something along the lines of a new dim value or when the table is being moved over define that you want the bucket?
Jun 23 '10 #5
agentmcmillan
4 New Member
Here is what I came up with this afternoon

Expand|Select|Wrap|Line Numbers
  1. Public Function fCalculatePercentiles(strName As String, sngPercentile As Single)
  2.  
  3. 'Make sure to 1st set a Reference to the
  4.  
  5. 'Microsoft Excel XX.X Object Library
  6.  
  7. Dim sngNumbers() As Single
  8.  
  9. Dim intNumberOfRecords As Integer
  10.  
  11. Dim objExcel As Excel.Application
  12.  
  13. Dim intCounter As Integer
  14.  
  15. Dim MyDB As DAO.Database
  16.  
  17. Dim rstPercentile As DAO.Recordset
  18.  
  19.  
  20.  
  21. Set MyDB = CurrentDb()
  22.  
  23. Set rstPercentile = MyDB.OpenRecordset("Select * from TBL_DATA WHERE [Name] = '" & strName & "'", dbOpenSnapshot)
  24.  
  25. rstPercentile.MoveLast: rstPercentile.MoveFirst     'accurate Record Count
  26.  
  27.  
  28.  
  29. intNumberOfRecords = rstPercentile.RecordCount
  30.  
  31.  
  32.  
  33. 'Redimension the Array to proper values
  34.  
  35. ReDim sngNumbers(1 To intNumberOfRecords)
  36.  
  37.  
  38.  
  39. Set objExcel = CreateObject("Excel.Application")
  40.  
  41.  
  42.  
  43. 'Populate the Array with values from the Recordset
  44.  
  45. For intCounter = 1 To intNumberOfRecords
  46.  
  47.   With rstPercentile
  48.  
  49.     sngNumbers(intCounter) = ![Days]
  50.  
  51.     .MoveNext
  52.  
  53.   End With
  54.  
  55. Next
  56.  
  57.  
  58.  
  59. 'Pass the Array to Excel's Percentile Function and Round the result to 2 Decimal Places
  60.  
  61. fCalculatePercentiles = Round(objExcel.Application.Percentile(sngNumbers(), sngPercentile), 2)
  62.  
  63.  
  64.  
  65. 'Don't forget to clean up!!!
  66.  
  67. rstPercentile.Close
  68.  
  69. Set rstPercentile = Nothing
  70.  
  71. objExcel.Quit
  72.  
  73. Set objExcel = Nothing
  74.  
  75. End Function
Jun 23 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

9
4554
by: Muzamil | last post by:
hi For an unavoidable reason, I have to use row-by-row processing (update) on a temporary table to update a history table every day. I have around 60,000 records in temporary table and about 2...
10
1525
by: Jakob Bieling | last post by:
Hi, somehow the prejudice of exceptions being rather slow (compared to, ie. returning an error value and checking that) keeps sticking around .. at least around me. I guess this is also why I...
36
5379
by: HERC777 | last post by:
just paste the below into notepad, call it iqsort.html double click it and your IE browser will run it. (neat! a universal programming language we can all run!) it falls out from the sort...
28
3736
by: Tony Johansson | last post by:
Hello! I can't figure out what point it is to use GetHashCode. I know that this GetHashCode is used for obtaining a unique integer value. Can somebody give me an example that prove the...
0
6905
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7041
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
6908
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5331
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4772
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4478
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2980
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1299
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
561
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.