PDA

Click to See Complete Forum and Search --> : [RESOLVED] Excel Formula Needed


MartinLiss
Jul 18th, 2005, 09:05 PM
In a column that contains numbers with values from 1 to 9, I'd like a formula that will calculate the percent of times that the number 1 shows up.

dglienna
Jul 18th, 2005, 11:04 PM
I always do things the easy way. If you ever wanted to use the number 2, then you'd have to recode all the statements to do it, which doesn't make sense.
There might be an easier way, but I would just use a cell that is a flag to whether your number is there or not, and then count the numbers, and the flags.

I did this, and formatted it as a percentage with 0 decimal places :wave:

MartinLiss
Jul 19th, 2005, 12:49 AM
Thanks but I don't want to add any extra columns or rows (even if I were to hidethem).

RobDog888
Jul 19th, 2005, 12:51 AM
How about just adding a filter? Then you could just count the rows. It would be dynamic too.

MartinLiss
Jul 19th, 2005, 01:00 AM
Sounds good but I'd have no idea how to do that. (I'll pick this up again tomorrow if someone responds).

RobDog888
Jul 19th, 2005, 01:05 AM
Place the active cell in the column and one row above the row data to be filtered.
Data > Filter > Autofilter. Then click on the combo box that appears and you get a choice of many options: filter by a particular unique
content, Top 10, All, Custom, Sort Asc, Sor Desc, etc.

dglienna
Jul 19th, 2005, 04:12 AM
I thought you wanted to do it programmatically. Adding a calculation column isn't a bad thing unless you are using all of them :)

visualAd
Jul 19th, 2005, 05:28 AM
You should use the COUNTIF() function for this. You can get it to count only the values which meet a certain criteria then use the COUNT() function to find the total number of cells in the range.

Highlight the range of cells you want to include in your formula and go to Insert->Name call the range numbers.
Find the cell where you want to calculate the percentage and enter the following formula.

=COUNTIF(numbers,1)/COUNT(numbers)

Format the cell as a percentage type by right clicking and clicking Format Cells

Have a look at the attachment to see the result.

MartinLiss
Jul 19th, 2005, 10:00 AM
You should use the COUNTIF() function for this. You can get it to count only the values which meet a certain criteria then use the COUNT() function to find the total number of cells in the range.

Highlight the range of cells you want to include in your formula and go to Insert->Name call the range numbers.
Find the cell where you want to calculate the percentage and enter the following formula.

=COUNTIF(numbers,1)/COUNT(numbers)

Format the cell as a percentage type by right clicking and clicking Format Cells

Have a look at the attachment to see the result.How do I define "numbers"?

visualAd
Jul 19th, 2005, 10:09 AM
Its just an easier way of specifying a range of cells. Highlight the cells you want to include in the range and then goto Name->Define in the Insert menu. You should then get a dialog box which enables you to give the range a name.

MartinLiss
Jul 19th, 2005, 10:12 AM
Thanks!