Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
maluli
 
Posts: n/a
Default What function will take the average of text data?

I have a range of unit types and I want to count each unit type and return
the one that occurs most often.
  #2   Report Post  
JE McGimpsey
 
Posts: n/a
Default

One way (array-entered: CTRL-SHIFT-ENTER or CMD-RETURN):

=INDEX(rng,MATCH(MAX(COUNTIF(rng,rng)),COUNTIF(rng ,rng),0))

Note: In cases where two or more types occur with equal, maximum
frequency, the first one in the list will be returned.


In article ,
maluli wrote:

I have a range of unit types and I want to count each unit type and return
the one that occurs most often.

  #3   Report Post  
Harlan Grove
 
Posts: n/a
Default

JE McGimpsey wrote...
One way (array-entered: CTRL-SHIFT-ENTER or CMD-RETURN):

=INDEX(rng,MATCH(MAX(COUNTIF(rng,rng)),COUNTIF(rn g,rng),0))

....

Somewhat shorter and more efficient is Leo Heuser's approach,

=INDEX(rng,MODE(MATCH(rng,rng,0)))

  #4   Report Post  
JE McGimpsey
 
Posts: n/a
Default

In article .com,
"Harlan Grove" wrote:

Somewhat shorter and more efficient is Leo Heuser's approach,

=INDEX(rng,MODE(MATCH(rng,rng,0)))


Thanks, Harlan!
  #5   Report Post  
Bob Phillips
 
Posts: n/a
Default

Harlan,

JE's formula does have one, significant IMO, advantage over that one, in
that it works if there are empty cells in the range, the second errors out.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Harlan Grove" wrote in message
oups.com...
JE McGimpsey wrote...
One way (array-entered: CTRL-SHIFT-ENTER or CMD-RETURN):

=INDEX(rng,MATCH(MAX(COUNTIF(rng,rng)),COUNTIF(rn g,rng),0))

...

Somewhat shorter and more efficient is Leo Heuser's approach,

=INDEX(rng,MODE(MATCH(rng,rng,0)))





  #6   Report Post  
Harlan Grove
 
Posts: n/a
Default

"Bob Phillips" wrote...
JE's formula does have one, significant IMO, advantage over that one,
in that it works if there are empty cells in the range, the second
errors out.

....

The other formula could be adapted.

=INDEX(rng,MODE(MATCH(rng&"",rng&"",0)))

That'd take care of blank cells. There's still another problem: if there are
only distinct entries in rng, MODE will return an error.


  #7   Report Post  
Bob Phillips
 
Posts: n/a
Default

I thought that when I tried it, and I tried it, but it didn't seem to work
then. I wondered if it was down to MODE, but thought I would post and you
might know the solution. Darn thing works now though, must have done it
wrongly.

Bob


"Harlan Grove" wrote in message
...
"Bob Phillips" wrote...
JE's formula does have one, significant IMO, advantage over that one,
in that it works if there are empty cells in the range, the second
errors out.

...

The other formula could be adapted.

=INDEX(rng,MODE(MATCH(rng&"",rng&"",0)))

That'd take care of blank cells. There's still another problem: if there

are
only distinct entries in rng, MODE will return an error.




  #8   Report Post  
Harlan Grove
 
Posts: n/a
Default

Bob Phillips wrote...
I thought that when I tried it, and I tried it, but it didn't seem to work
then. I wondered if it was down to MODE, but thought I would post and you
might know the solution. Darn thing works now though, must have done it
wrongly.

....

It'd be nice if Excel could treat blank (VB Empty) values consistently.
If rng contains at least one blank cell, MATCH("",rng,0),
MATCH(0,rng,0) and MATCH(IV65536,rng,0) all return #N/A. That leads me
to suspect that Excel always converts blank values in MATCH's 1st
arguement to 0 but doesn't convert the values in MATCH's 2nd argument,
and 0 < blank in MATCH comparisons.

  #9   Report Post  
Aladin Akyurek
 
Posts: n/a
Default

Let A3:A13 house the following sample:

{"Name";"XZA";"XZA";"SDA";"XZA";"SDA";"XFA";"PQA"; "PQA";"XFA";"XFA"}

where A3 is a header, while A4, A5, and so on are text values.

The problem: What is the text value which is the most frequent?

A1: N

which is a label.

B1: 1

which signifies "the one that occurs most often".

A2: Ties of the Nth

which is a label.

B2:

=MAX(IF(INDEX(B4:B13,MATCH(B1,C4:C13,0))=B4:B13,C4 :C13))-B1

which must be confirmed with control+shift+enter, not just with enter.

B3: Count

which is a label.

B4, copied down:

=IF(ISNUMBER(MATCH(A4,$A$3:A3,0)),"",COUNTIF($A$4: $A$13,A4))

C3: Rank

which is a label.

C4, copied down:

=IF(N(B4),RANK(B4,$B$4:$B$13)+COUNTIF($B$4:B4,B4)-1,"")

D3: Most Freq

which is just a label.

D4, copied down:

=IF(ROW()-ROW($D$4)+1<=$B$1+$B$2,INDEX($A$4:$A$13,MATCH(ROW( )-ROW($D$4)+1,$C$4:$C$13,0)),"")

The result that you get in column D is a list, consisting one or more
items...

{"Most Freq";"XZA";"XFA"}

Standard formulas would give you just one item, a result that is not
correct.

maluli wrote:
I have a range of unit types and I want to count each unit type and return
the one that occurs most often.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using The Average Function if a cell has NA carl Excel Worksheet Functions 6 May 21st 23 07:46 PM
Formulas dealing with text data Bagia Excel Worksheet Functions 6 June 20th 05 10:29 PM
Web Services function call and data refreshing Jonathan Stone Excel Worksheet Functions 0 June 1st 05 02:43 AM
input text at front of field that contains data Steve M Excel Discussion (Misc queries) 3 May 16th 05 12:28 AM
average function in Excel 2002 Sherry New Users to Excel 13 May 8th 05 01:49 PM


All times are GMT +1. The time now is 11:48 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"