Question : ranking records and determining percentage of total in access 2007

Hi,

I have a small problem I need some help solving.  I have a table that is a summary of cost drivers for an aviation program.  Each record is a unique part number.  I need to be able to rank each record by cost and generate a % of that cost.  There are several categories I need to do this for but if I can get help with one I can carry that solution to the rest.

My table is as follows:

Partnumber (text)
support_cost (currency)
support_Per(number)
support_rank(number)

I need to be able to rank from 1 to .....  the number of records with one being the rank for the highest cost in support_cost

I need to be able to make support_per a percentage of the sum of support_cost

I would like to be able to do this in VBA to go along with the rest of what we are doing with this.  There are several catagories for other factors that we will do this for as well in order to derive a composite rank for each part number.

Thank you in advance for your help.  

Semper Fi,

Jeff

Answer : ranking records and determining percentage of total in access 2007

Ah, then you should definitely not store it, because if you add, delete or modify any other record then it will invalidate all the stored values.

This should work:

SELECT Partnumber, support_cost,
    support_cost / DSum( "support_cost", "YourTable" ) as support_per,
    DCount( "*", "YourTable", "support_cost>" & support_cost ) + 1 as support_rank
    from YourTable order by support_cost desc;

In the quert design view, you can set the Format property of the field to Percent.

--
Graham

Random Solutions  
 
programming4us programming4us