+ Reply to Thread
Results 1 to 11 of 11

Rank - Disregard the zero values and write the formula for values in another worksheet

  1. #1
    Forum Contributor
    Join Date
    05-01-2013
    Location
    Richmond, VA
    MS-Off Ver
    Excel 365
    Posts
    164

    Rank - Disregard the zero values and write the formula for values in another worksheet

    I need to write a formula to rank rows of data with some of them having zero values that I want the rank to completely ignore. The formula needs to reference data in a different worksheet as well. Currently the formula for one row reads:
    =RANK(RANK_MILES!B3,RANK_MILES!$B$3:$J$3)

    There are nine vendors in this case with the values identified in columns B3 through J3. However, some of them did not submit any values. In this case, I do not want those without any values to even be considered in the ranking.

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Rank - Disregard the zero values and write the formula for values in another worksheet

    Try this

    =IF(OR(Rank_Miles!B3=0, Rank_Miles!B3=""), "",RANK(Rank_Miles!B3,Rank_Miles!$B$3:$J$3))
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,937

    Re: Rank - Disregard the zero values and write the formula for values in another worksheet

    To perform a conditonal Rank, use SUMPRODUCT:

    This gives a lower rank to lower numbers.

    =IF(RANK_MILES!B3=0,"",SUMPRODUCT((RANK_MILES!$B$3:$J$3<>0)*(RANK_MILES!$B$3:$J$3<RANK_MILES!B3))+1)
    Last edited by Bernie Deitrick; 09-15-2014 at 01:06 PM.
    Bernie Deitrick
    Excel MVP 2000-2010

  4. #4
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Rank - Disregard the zero values and write the formula for values in another worksheet

    I went with a similar formula to Bernie:

    =IF(RANK_MILES!B3<>0,((SUMPRODUCT((RANK_MILES!$B$3:$J$3>0)*(RANK_MILES!$B$3:$J$3>B3))+1)+COUNTIFS(RANK_MILES!$B$3:B3,B3,RANK_MILES!$B$3:B3,"<>"&B3)-1)+1,"")
    Attached Files Attached Files
    Last edited by daffodil11; 09-15-2014 at 01:05 PM. Reason: i am a potato
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

  5. #5
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,937

    Re: Rank - Disregard the zero values and write the formula for values in another worksheet

    Your formula does not ignore the 0 values when considering the population the value is ranked against - it just does not rank 0 values. And ranking against zero is only an issue if the ranking order is non-default: i.e., Rank(Number, Ref, 1) instead of Rank(Number, Ref) or Rank(Number, Ref, 0)

  6. #6
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Rank - Disregard the zero values and write the formula for values in another worksheet

    True, didn't think it through. Thanks Bernie.

  7. #7
    Forum Contributor
    Join Date
    05-01-2013
    Location
    Richmond, VA
    MS-Off Ver
    Excel 365
    Posts
    164

    Re: Rank - Disregard the zero values and write the formula for values in another worksheet

    Thank you for the responses! I have been detoured with writing another function so I will not be trying out this rank statement until this other one is resolved.

  8. #8
    Forum Contributor
    Join Date
    05-01-2013
    Location
    Richmond, VA
    MS-Off Ver
    Excel 365
    Posts
    164

    Re: Rank - Disregard the zero values and write the formula for values in another worksheet

    Thank you for this formula Bernie. One more question. How would I write this to reverse the order of the ranking?

  9. #9
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Rank - Disregard the zero values and write the formula for values in another worksheet

    Just flip the Less Than Sign.

    =IF(RANK_MILES!B3=0,"",SUMPRODUCT((RANK_MILES!$B$3:$J$3<>0)*(RANK_MILES!$B$3:$J$3<RANK_MILES!B3))+1)

    =IF(RANK_MILES!B3=0,"",SUMPRODUCT((RANK_MILES!$B$3:$J$3<>0)*(RANK_MILES!$B$3:$J$3>RANK_MILES!B3))+1)

  10. #10
    Forum Contributor
    Join Date
    05-01-2013
    Location
    Richmond, VA
    MS-Off Ver
    Excel 365
    Posts
    164

    Re: Rank - Disregard the zero values and write the formula for values in another worksheet

    Thank you!

  11. #11
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Rank - Disregard the zero values and write the formula for values in another worksheet

    No problem, glad we could help out.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Formula to Rank and populate values base don Rank
    By Excel Dumbo in forum Excel General
    Replies: 3
    Last Post: 10-09-2012, 02:02 AM
  2. Concatenate and disregard zero values
    By sans in forum Excel General
    Replies: 10
    Last Post: 11-06-2011, 03:47 PM
  3. Replies: 7
    Last Post: 08-13-2010, 01:12 PM
  4. Write Unique Values to New Worksheet
    By John_Carty in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-02-2005, 06:20 PM
  5. Write Unique Values to New Worksheet
    By John_Carty in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-02-2005, 06:17 PM

Tags for this Thread

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