Solved

Formula

Posted on 2011-03-23
11
216 Views
Last Modified: 2012-08-14
Trying to build a formula:

To look in R3:R24 and find which value appears the most either GA, GB, GC, GD, GE, or GF. If there is an instance where two or more of the values appear the most, then take the first value.
0
Comment
Question by:sandramac
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 2
  • 2
  • +1
11 Comments
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 35204948
Here is one way to do it. Sample file attached. Hope this is what you wanted?

=IF(COUNTIF(R3:R24,"GA")=MAX(COUNTIF(R3:R24,"GA"),COUNTIF(R3:R24,"GB"),COUNTIF(R3:R24,"GC"),COUNTIF(R3:R24,"GD"),COUNTIF(R3:R24,"GE"),COUNTIF(R3:R24,"GF")),"GA",IF(COUNTIF(R3:R24,"GB")=MAX(COUNTIF(R3:R24,"GA"),COUNTIF(R3:R24,"GB"),COUNTIF(R3:R24,"GC"),COUNTIF(R3:R24,"GD"),COUNTIF(R3:R24,"GE"),COUNTIF(R3:R24,"GF")),"GB",IF(COUNTIF(R3:R24,"GC")=MAX(COUNTIF(R3:R24,"GA"),COUNTIF(R3:R24,"GB"),COUNTIF(R3:R24,"GC"),COUNTIF(R3:R24,"GD"),COUNTIF(R3:R24,"GE"),COUNTIF(R3:R24,"GF")),"GC",IF(COUNTIF(R3:R24,"GD")=MAX(COUNTIF(R3:R24,"GA"),COUNTIF(R3:R24,"GB"),COUNTIF(R3:R24,"GC"),COUNTIF(R3:R24,"GD"),COUNTIF(R3:R24,"GE"),COUNTIF(R3:R24,"GF")),"GD",IF(COUNTIF(R3:R24,"GE")=MAX(COUNTIF(R3:R24,"GA"),COUNTIF(R3:R24,"GB"),COUNTIF(R3:R24,"GC"),COUNTIF(R3:R24,"GD"),COUNTIF(R3:R24,"GE"),COUNTIF(R3:R24,"GF")),"GE",IF(COUNTIF(R3:R24,"GF")=MAX(COUNTIF(R3:R24,"GA"),COUNTIF(R3:R24,"GB"),COUNTIF(R3:R24,"GC"),COUNTIF(R3:R24,"GD"),COUNTIF(R3:R24,"GE"),COUNTIF(R3:R24,"GF")),"GF","Not Found"))))))

Sid
Book1.xlsx
0
 

Author Comment

by:sandramac
ID: 35204967
I tried the formula, in my current data in R3:R24, there is zero instance of any of the values, but it returns a 'GA", it should just be blank.
0
 
LVL 50

Expert Comment

by:barry houdini
ID: 35204968
If it's only those values then try this array formula

=INDEX(R3:F24,MODE(MATCH(R3:F24,R3:F24,0)))

Confirmed with CTRL+SHIFT+ENTER

assumed no blanks in the range.....

Regards, barry
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:sandramac
ID: 35204995
barry there is the possibility of a blank in there
0
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 35205155
>>>>I tried the formula, in my current data in R3:R24, there is zero instance of any of the values, but it returns a 'GA", it should just be blank.

Try this File

Sid
Book1.xlsx
0
 
LVL 50

Expert Comment

by:barry houdini
ID: 35205162
Ok try this version....



=IF(SUM(COUNTIF(R3:F24,{"GA","GB","GC","GD","GE","GF"})),INDEX(R3:F24,MODE(IF(ISNUMBER(MATCH(R3:R24,{"GA","GB","GC","GD","GE","GF"},0)),MATCH(R3:F24,R3:F24,0)*{1,1},""))),"")

With CSE again

regards, barry
0
 
LVL 50

Expert Comment

by:barry houdini
ID: 35205170
Ok try this version....



=IF(SUM(COUNTIF(R3:F24,{"GA","GB","GC","GD","GE","GF"})),INDEX(R3:F24,MODE(IF(ISNUMBER(MATCH(R3:R24,{"GA","GB","GC","GD","GE","GF"},0)),MATCH(R3:F24,R3:F24,0)*{1,1},""))),"")

With CSE again

regards, barry
0
 
LVL 50

Expert Comment

by:barry houdini
ID: 35205197
Sorry, some ranges in that formula are wrongly shown ad R3:F24, change to R3:F24....

=IF(SUM(COUNTIF(R3:R24,{"GA","GB","GC","GD","GE","GF"})),INDEX(R3:R24,MODE(IF(ISNUMBER(MATCH(R3:R24,{"GA","GB","GC","GD","GE","GF"},0)),MATCH(R3:R24,R3:R24,0)*{1,1},""))),"")

barry
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 35205207
Barry, why not simply

=INDEX(R3:R24,MODE(IF(ISNA(MATCH(R3:R24,R3:R24,0)),FALSE,MATCH(R3:R24,R3:R24,0))))
0
 
LVL 50

Expert Comment

by:barry houdini
ID: 35205358
Hello Saqib,

Yes, that would cope with blanks but won't work if the most common value has only 1 instance (e.g.the only value is GA in R3) or if the whole range is blank. Also I wasn't sure whether there might be other values besides "GA", "GB" etc. so if there are entries like "xyz" or 123 then my suggested formula will ignore those, see attached

regards, barry
26908131.xls
0
 
LVL 50

Accepted Solution

by:
barry houdini earned 500 total points
ID: 35205396
but having said that......two shorter options to do the same.

In Excel 2007 or later

=IFERROR(INDEX(R3:R24,MODE(IF(ISNUMBER(MATCH(R3:R24,{"GA","GB","GC","GD","GE","GF"},0)),MATCH(R3:R24,R3:R24,0)*{1,1}))),"")

or in any version

=LOOKUP("zzz",IF({1,0},"",INDEX(R3:R24,MODE(IF(ISNUMBER(MATCH(R3:R24,{"GA","GB","GC","GD","GE","GF"},0)),MATCH(R3:R24,R3:R24,0)*{1,1})))))

both require CTRL+SHIFT+ENTER as before

regards, barry
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question