?
Solved

Explain this formula please

Posted on 2012-03-10
3
Medium Priority
?
308 Views
Last Modified: 2012-08-13
could someone please explain what this formula is doing..?

{=MODE(IF(COUNTIF(A$43:A43,DATA!J2:J65535)=0,DATA!J2:J65535+{0,0}))}
0
Comment
Question by:Friggin_Lazy
[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
  • 2
3 Comments
 
LVL 50

Accepted Solution

by:
barry houdini earned 2000 total points
ID: 37704966
MODE finds the most common number in a set of numbers. In this case, initially, it's finding the most common number in the range DATA!J2:J65535.

Assuming the formula starts in A44 and A43 is blank or has a text value then the IF function uses COUNTIF to count how many times each value in DATA!J2:J65535 appears in the cell A43 - that will presumably be zero for all of them so in A44 nothing is excluded and the formula gives the most common number.

In A45, though, the range in COUNTIF changes to include A44 so now any value in DATA!J2:J65535 that matches the top value already chosen in A44 is excluded, so you get the MODE without that value, i.e. the second most common number.

This repeats as you go down so you then get the 3rd most common number in A46, 4th in A47 until all numbers in the range are exhausted, then you'll get an #N/A error.

MODE gives an #N/A error if there are no repeated values so +{0,0} is used to "double-up" all values, thus ensuring there are no #N/A values returned even for numbers which only appear once in column J.

This is an "array formula" which needs to be confirmed with CTRL+SHIFT+ENTER

Is it working OK for you? Normally if copied down you need to make the J2:J65535 range "absolute", i.e. put $ signs in like this

=MODE(IF(COUNTIF(A$43:A43,data!J$2:J$65535)=0,data!J$2:J$65535+{0,0}))

I note that the formula will count blank cells as zeroes so unless the range is fully populated you might find, erroneously, that zero appears high up the list, if you don't want that then restrict the range to the populated part of Data!J2:J65535 or change to this version to exclude blanks

=MODE(IF(data!J2:J65535<>"",IF(COUNTIF(A$43:A43,data!J2:J65535)=0,data!J2:J65535+{0,0})))

regards, barry
0
 

Author Closing Comment

by:Friggin_Lazy
ID: 37706587
thank you Barry for providing this great explination.  ( :
0
 
LVL 50

Expert Comment

by:barry houdini
ID: 37706591
Thank you. Sorry, I notice that the $ signs weren't included in that last formula, so the suggested formula to copy down and exclude blanks should be

=MODE(IF(data!J$2:J$65535<>"",IF(COUNTIF(A$43:A43,data!J$2:J$65535)=0,data!J$2:J$65535+{0,0})))

regards, barry
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
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 on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

771 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