+ Reply to Thread
Results 1 to 20 of 20

Ranking Formula which ignores zeros, has both positive and negative values,

  1. #1
    Registered User
    Join Date
    03-18-2022
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    8

    Ranking Formula which ignores zeros, has both positive and negative values,

    Hi

    I am looking to rank the data in the far right column but need to;

    - Ignore zeros
    - Has positive and Negative values which I want to rank together
    - Data contains duplicates so needs to give unique rank for these

    Sample attached....

    Martin
    Attached Files Attached Files
    Last edited by Martin85; 03-28-2022 at 04:50 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: Ranking Formula which ignores zeros, has both positive and negative values,

    Try:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Ranking Formula which ignores zeros, has both positive and negative values,

    Hi Martin and welcome to the forum,

    Try this in I3 and pull down:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    If you want it to start at 1 instead of zero then try this:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Countifs and no zero.xlsx
    Last edited by MarvinP; 03-28-2022 at 04:24 PM.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  4. #4
    Registered User
    Join Date
    03-18-2022
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    8

    Re: Ranking Formula which ignores zeros, has both positive and negative values,

    Thanks, but not quite what I was looking for this sorts them but I want to pull the ranked data in to another table including product names so was looking for a way to do this within a rank formula or something similar.

    Currently using the following but it ignores the zeros and any negatives end up at the far end of the rank of over 600 lines.

    IF($M143=0,"",IF(M143=0,"",RANK(M143,M$5:M$624,0)+COUNTIF(M$5:M143,M143)-1))

  5. #5
    Registered User
    Join Date
    03-18-2022
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    8

    Re: Ranking Formula which ignores zeros, has both positive and negative values,

    Thanks for the welcome and the formula, looks like that works, the formula that you have given ranks from smallest to biggest can that be flipped around within the count if?

  6. #6
    Registered User
    Join Date
    03-18-2022
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    8

    Re: Ranking Formula which ignores zeros, has both positive and negative values,

    Apologies MarvinP this works for the positives and negatives but doesn't treat duplicates as unique references, apologies I left this out of my original post, now amended.

  7. #7
    Valued Forum Contributor
    Join Date
    07-23-2013
    Location
    London, England
    MS-Off Ver
    Office 365
    Posts
    988

    Re: Ranking Formula which ignores zeros, has both positive and negative values,

    What do you mean by rank "together"? Do you mean rank ignoring the sign?

    e.g. do you want to rank 2,1,-3,-4 or -4,-3,2,1?

    It sounds like a slight tweak to TMS's solution is what you want:

    =LET(a,UNIQUE(SORT(FILTER(B:H,(H:H<>0),(H:H<>"")),7,-1)),IF(a=0,"",a))

    Though I'm not entirely sure how you want to define duplicates (eg whole row unique, or just product). It would be helpful if you put in the results you are after (not with a formula) for some example situations.

  8. #8
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Ranking Formula which ignores zeros, has both positive and negative values,

    Hey Martin,

    After working on this for a while, I realized I need a better example with zeros and duplicates and what you are pulling from the other table and products, etc. I think we can get a great answer if we see a bigger picture of the problem.

  9. #9
    Registered User
    Join Date
    03-18-2022
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    8

    Re: Ranking Formula which ignores zeros, has both positive and negative values,

    Hi All,

    Thank you for all help.

    I have attached an extended sample with duplicates and zeros in the data with both the countif result and the result I want hardcoded to one side.

    With reference to the duplicates I wanted to be able to rank them uniquely, with all data going from highest to lowest so that I end up with a rank for all items that are not zero. These non zero items are then looked up on another table which pulls through the items for each catagory giving product name, qty and price so whatever solution I apply I need to be able to keep the data together so that the name etc can also be retreived.

    Hope this makes sense.
    Attached Files Attached Files
    Last edited by Martin85; 03-29-2022 at 04:07 AM.

  10. #10
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,463

    Re: Ranking Formula which ignores zeros, has both positive and negative values,

    I3:
    Please Login or Register  to view this content.
    Drag down
    Quang PT

  11. #11
    Registered User
    Join Date
    03-18-2022
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    8

    Re: Ranking Formula which ignores zeros, has both positive and negative values,

    Thank you, can this be done without the absolutes, realised in the example I gave you it ranked the negatives the wrong way around so -12 should be below -10? Apologies for the confusion

  12. #12
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,463

    Re: Ranking Formula which ignores zeros, has both positive and negative values,

    Maybe try to remove abs?
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    03-18-2022
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    8

    Re: Ranking Formula which ignores zeros, has both positive and negative values,

    Then skips the ranks for the zeros so end up with 1,2,3,4,8,9

  14. #14
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,463

    Re: Ranking Formula which ignores zeros, has both positive and negative values,

    Could you put my formula in file and manual type expected ranking then upload again?

  15. #15
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: Ranking Formula which ignores zeros, has both positive and negative values,

    Maybe this:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    03-18-2022
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    8

    Re: Ranking Formula which ignores zeros, has both positive and negative values,

    Think I have found the solution using a combination

    IF(H3=0,"",COUNTIFS($H$3:$H$11,">"&H3,$H$3:$H$11,"<>0")+COUNTIF(H$3:H3,H3))

    Thank you all for your help

  17. #17
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: Ranking Formula which ignores zeros, has both positive and negative values,

    Or, the COUNTIF modified.

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  18. #18
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: Ranking Formula which ignores zeros, has both positive and negative values,

    Ah yes, I could have cancelled the +1 and -1

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  19. #19
    Registered User
    Join Date
    02-20-2024
    Location
    India
    MS-Off Ver
    O365
    Posts
    1

    Re: Ranking Formula which ignores zeros, has both positive and negative values,

    if there are same values in multiple rows, this formula gives same rank to all. Is it possible to give separate ranks to same values? For example if my data is 6,5,4,4,0,-2,-4,-4 then in descending order, my rank should be 1,2,3,4,,5,6,7 i.e. not duplicating rank while skipping rank for 0.

  20. #20
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,025

    Re: Ranking Formula which ignores zeros, has both positive and negative values,

    vvisheshvv

    Hi.

    It's a forum rule that you start your own thread, rather than "piggy-backing" on someone else's thread. Why is it a rule?

    1. It helps prevent massive confusion arising - which will happen if it is not clear which question is being answered.

    2. The forum provides a public database for questions and answers. One thread = one question. Your problem will almost certainly be somewhat different.

    So please start your own thread and explain your own problem (make sure that, right from the start, you use a meaningful title (NOT things like "help needed" or "urgent problem"... think of the Google search terms that you would use to find the solution).

    A picture is worth 1,000 words. An Excel sheet is worth 1,000 pictures. So, prepare a SMALL sample sheet (10-20 rows, not thousands!!!). Make sure there is enough data to demonstrate your need. Make sure your desired results are shown, mock them up manually if necessary. Remember to remove ALL confidential information first!!!


    The yellow banner about sample worksheets, at the top of the screen tells you how to post a sheet here on the Forum.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

+ 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. Ranking data that include both positive and negative numbers
    By DrNick31522 in forum Hello..Introduce yourself
    Replies: 2
    Last Post: 04-23-2021, 09:41 PM
  2. Ranking positive and negative numbers
    By norms in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 10-20-2019, 03:57 AM
  3. Ranking Positive and Negative Numbers in a Column
    By tim.morley in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-09-2018, 10:43 AM
  4. [SOLVED] Ranking with duplicate values while ignoring zeros and negative values
    By mfortier3 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-06-2017, 04:43 AM
  5. Replies: 3
    Last Post: 11-24-2016, 05:26 AM
  6. [SOLVED] Ranking Groups of Combined Positive and Negative Values
    By hammer2 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 11-24-2016, 04:19 AM
  7. Replies: 4
    Last Post: 09-26-2005, 06:05 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