+ Reply to Thread
Results 1 to 10 of 10

Excluding Zeros from CORREL Function

  1. #1
    Registered User
    Join Date
    12-03-2006
    Posts
    12

    Excluding Zeros from CORREL Function

    How do you exclude zeros from being included in correlation functions?

    1 0
    2 3
    2 0
    1 0
    3 0
    3 3
    3 2
    2 3


    If that was a spreadsheet, I would want to calculate the correlation between the pairs without a zero.

    I have tried this formula without success.

    =CORREL((IF(D3:D9<>0,C3:C9,"")),(IF(D3:D9<>0,D3:D9,"")))

    Thank you for your help

  2. #2
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: Excluding Zeros from CORREL Function

    =correl(if(c3:c9,c3:c9),if(d3:d9,d3:d9))
    should work (similar to yours but a bit simpler)
    needs entering with ctrl+shift+enter
    when you do so, curly brackets should appear around the formula, comme ca:
    {=correl(if(c3:c9,c3:c9),if(d3:d9,d3:d9))}

    hth
    CC


    If you feel really indebted please consider a donation to charity. My preferred charity is ActionAid but there are plenty of worthy alternatives.

  3. #3
    Registered User
    Join Date
    12-03-2006
    Posts
    12

    Re: Excluding Zeros from CORREL Function

    I tried this but it still returned a #DIV/0 error.

  4. #4
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: Excluding Zeros from CORREL Function

    You need at least two matching pairs for correl not to return div0

  5. #5
    Registered User
    Join Date
    12-03-2006
    Posts
    12

    Re: Excluding Zeros from CORREL Function

    How do I write a formula that will skip a row that has a 0 in it?

  6. #6
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: Excluding Zeros from CORREL Function

    formula provided does so...

  7. #7
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Excluding Zeros from CORREL Function

    Perhaps OP means if 0 appears in either cell ignore - as opposed to just in D ?

    =CORREL(IF(C3:C9*D3:D9,C3:C9),IF(C3:C9*D3:D9,D3:D9))
    confirmed with CTRL + SHIFT + ENTER

  8. #8
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: Excluding Zeros from CORREL Function

    My understanding, I would love to be corrected (I note I'm now a 'forum guru' and think this is hardly justified, so let's prove why I shouldn't be...)

    =correl(if(c3:c9,c3:c9),if(d3:d9,d3:d9))

    from help:
    If an array or reference argument contains text, logical values, or empty cells, those values are ignored; however, cells with the value zero are included.

    Of course, you can test it.
    1 | =a1^2
    2 | "
    3 | "
    4 | "
    5 | "
    (quadratic relationship -> every pairing must deviate from linear, hence removing any pairing changes correl result)

    correl on ranges
    delete 4, number changes, replace 4, delete =a4^2, correl = same as when 4 was deleted

    This makes me think (with aid of help) that a blank in either x or y at any array point excludes the array pairing from correl (after all, what is the 'other' number correlating to???)

    That is why if OP had:
    1 | blank
    blank | 2
    3 | blank
    blank | 4
    5 | 5

    would return div0 as only 1 pair of numbers to correlate - which is what i was alluding to in post 4

    Based on this logic, this would also work:
    =correl(if(d3:d9,c3:c9),if(c3:c9,d3:d9))
    or indeed
    =correl(if((c3:c9*d3:d9),c3:c9),d3:d9)
    (which is my new favourite answer)

    Your correction is very welcome

  9. #9
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Excluding Zeros from CORREL Function

    You're correct - for some reason I was basing my reply on OP's post of:

    Please Login or Register  to view this content.
    rather than your suggestion ... the above obviously has a different outcome but you had already accounted for that in your first response - apologies.

    I would say your Guru status is well deserved CC (and overdue) - next stop - Moderator !

  10. #10
    Registered User
    Join Date
    12-03-2006
    Posts
    12

    Re: Excluding Zeros from CORREL Function

    I'm sorry when I first tried it yesterday I must have entered it wrong because it didn't work, when I tried it today it worked perfectly.

    Thank you so much for your help

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1