+ Reply to Thread
Results 1 to 24 of 24

Ranking on cell value and getting number of unique value

  1. #1
    Forum Contributor
    Join Date
    03-15-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2019
    Posts
    327

    Ranking on cell value and getting number of unique value

    Hello friends,

    I am trying to do the following in my investment portfolio, need help on a couple of things. Pls see attached excel file.

    There are 2 sheets, with 2 different lists of stocks.

    Column D = Industry Name
    Column E = Stock Name
    Column G = Points based on internal analysis

    Cell D1 = Formula to get number of unique industries
    Cell E1 = COUTNA formula to get number of stocks

    Column I = Ranking based on values in column G

    Here is where I need help:

    #1

    Cell D1 = How do I edit this formula so that it can be replicated across sheets with different number of stocks so that I get the right value?

    If you notice, Sheet 1 has 53 stocks and Sheet 2 has 46 stocks. I have had to edit the formulas according to number of stocks

    Sheet 1 > Cell D1 = {=SUM(1/COUNTIF($D$3:$D$55,$D$3:$D$55))}

    Sheet 2 > Cell D1 = {=SUM(1/COUNTIF($D$3:$D$48,$D$3:$D$48))}

    If I use the Sheet 1 formula in Sheet 2, it gives an error because the number of stocks is 46 compared to 53 rows...

    Let us work with the assumption that there will be a maximum of 200 stocks (rows with sector names)


    #2

    I need to put a ranking formula in cell I1 and copy it down till the last stock in the portfolio. Here again, I need to keep adjusting the row reference.

    Sheet 1 > Cell I1 = RANK(G3,$G$3:$G$55,0)

    Sheet 2 > Cell I1 = RANK(G3,$G$3:$G$48,0)

    How do I edit the formula in cell I1 so that it automatically takes the row reference by starting from $G$3 to row number based on value in cell E1?

    Sheet 1 would be: $G$3:$G$55 (starting row = 3, number of stocks = 53... so it would be 3 + 53 - 1 = 55)

    Sheet 2 would be: $G$3:$G$48 (starting row = 3, number of stocks = 46... so it would be 3 + 48 - 1 = 48)

    ... and the formula uses the COUNTIF function if there are duplicate values in column G

    Many thanks in advance...

    Regards,
    Navin
    Last edited by AliGW; 07-15-2024 at 02:18 AM. Reason: Title edited for legibility - don't use underscores, please.
    Regards,
    Navin Agrawal

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    91,060

    Re: Navin_Ranking_on_cell_value_and_getting_number_of_unique_value

    Please don't use underscores in your thread titles - it makes them difficult to read. Thanks.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    91,060

    Re: Ranking on cell value and getting number of unique value

    Where have you mocked up some expected results?

    A good sample workbook has just 10-20 rows of representative data that has been desensitised. The sample layout accurately matches that of your real data. It also has expected results mocked up, worked examples where required, relevant cells highlighted and a few explanatory notes.

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,905

    Re: Ranking on cell value and getting number of unique value

    Dynamic Named ranges

    e.g industry1

    =OFFSET(Sheet1!$D$3,,,COUNTIF(Sheet1!$D$3:$D$300,"<>"),1)

    in D1

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    =SUM(1/COUNTIF(industry1,industry1))[/FORMULA]

    points1

    =OFFSET(Sheet1!$G$3,,,COUNTIF(Sheet1!$G$3:$G$300,"<>"),1)

    in I3

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


    Similar for sheet2
    Last edited by JohnTopley; 07-15-2024 at 02:41 AM.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  5. #5
    Forum Contributor
    Join Date
    03-15-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2019
    Posts
    327

    Re: Navin_Ranking_on_cell_value_and_getting_number_of_unique_value

    Quote Originally Posted by AliGW View Post
    Please don't use underscores in your thread titles - it makes them difficult to read. Thanks.
    Point noted @Ali... Thanks

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    91,060

    Re: Ranking on cell value and getting number of unique value

    Please respond to post #4.

  7. #7
    Forum Contributor
    Join Date
    03-15-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2019
    Posts
    327

    Re: Ranking on cell value and getting number of unique value

    Thank you @JohnTopley...

    In that case, I will have to define a separate range for each of them on each sheet... I have about 50 - 75 sheets in the file... this would mean defining more than 100 ranges!!!

    Is there any other solution which is more standardized to be merely copied on each sheet?

    Many thanks...

    Regards,
    Navin
    Last edited by AliGW; 07-15-2024 at 03:31 AM. Reason: Please don't quote unnecessarily - use the Quick Reply button instead.

  8. #8
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,905

    Re: Ranking on cell value and getting number of unique value

    in D1

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


    in I3

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

  9. #9
    Forum Expert
    Join Date
    04-14-2009
    Location
    Taiwan
    MS-Off Ver
    Excel 2016,2019,O365
    Posts
    2,929

    Re: Ranking on cell value and getting number of unique value

    D1 committed with Ctrl+Shift+Enter
    Please Login or Register  to view this content.
    I3 copied down.
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    03-15-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2019
    Posts
    327

    Re: Ranking on cell value and getting number of unique value

    #8

    Thank you @ JohnTopley... This works

    However, it does not solve the issue if there is a duplicate value in column G... it returns a duplicate rank instead of giving a next rank...

    Regards,
    Navin

  11. #11
    Forum Contributor
    Join Date
    03-15-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2019
    Posts
    327

    Re: Ranking on cell value and getting number of unique value

    #9

    Thank you @Windknife... This works

    However, it does not solve the issue if there is a duplicate value in column G... it returns a duplicate rank instead of giving a next rank...

    Regards,
    Navin

  12. #12
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,905

    Re: Ranking on cell value and getting number of unique value

    There are no duplicates in the supplied data so post file with duplicates.

  13. #13
    Forum Expert
    Join Date
    04-14-2009
    Location
    Taiwan
    MS-Off Ver
    Excel 2016,2019,O365
    Posts
    2,929

    Re: Ranking on cell value and getting number of unique value

    Try this in I3.

    Please Login or Register  to view this content.

  14. #14
    Forum Contributor
    Join Date
    03-15-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2019
    Posts
    327

    Re: Ranking on cell value and getting number of unique value

    #12
    @JohnTopley: Thank you very much... Query solved...

    #13
    @windknife: Thank you very much... Query solved...

  15. #15
    Forum Expert
    Join Date
    04-14-2009
    Location
    Taiwan
    MS-Off Ver
    Excel 2016,2019,O365
    Posts
    2,929

    Re: Ranking on cell value and getting number of unique value

    You are welcome.

  16. #16
    Forum Contributor
    Join Date
    03-15-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2019
    Posts
    327

    Re: Ranking on cell value and getting number of unique value

    Quote Originally Posted by windknife View Post
    Try this in I3.

    Please Login or Register  to view this content.
    @windknife: If I may bother you?

    How do I exclude those members from ranking who have ZERO value...

    Many thanks

  17. #17
    Forum Expert
    Join Date
    04-14-2009
    Location
    Taiwan
    MS-Off Ver
    Excel 2016,2019,O365
    Posts
    2,929

    Re: Ranking on cell value and getting number of unique value

    How about this?
    Please Login or Register  to view this content.

  18. #18
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    91,060

    Re: Ranking on cell value and getting number of unique value

    Is this what you need?

    =IF(OR(G3=0,G3=""),"",COUNTIFS($G$3:G100,">="&G3,$G$3:G100,"<>"&0))

  19. #19
    Forum Contributor
    Join Date
    03-15-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2019
    Posts
    327

    Re: Ranking on cell value and getting number of unique value

    #17
    @windknife: Thank you very much... It works... Query solved...

    #18
    @Ali: Thank you very much... It works... Query solved...

  20. #20
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    91,060

    Re: Ranking on cell value and getting number of unique value

    You're welcome.

  21. #21
    Forum Contributor
    Join Date
    03-15-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2019
    Posts
    327

    Re: Ranking on cell value and getting number of unique value

    Quote Originally Posted by windknife View Post
    How about this?
    Please Login or Register  to view this content.
    @windknife

    Pls see attached file... The ranking starts from 0 instead of 1
    Attached Files Attached Files

  22. #22
    Forum Expert
    Join Date
    04-14-2009
    Location
    Taiwan
    MS-Off Ver
    Excel 2016,2019,O365
    Posts
    2,929

    Re: Ranking on cell value and getting number of unique value

    B2
    Please Login or Register  to view this content.
    Attached Files Attached Files

  23. #23
    Forum Contributor
    Join Date
    03-15-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2019
    Posts
    327

    Re: Ranking on cell value and getting number of unique value

    #22

    Thank you @windknife... it works now... Appreciate it...

  24. #24
    Forum Expert
    Join Date
    04-14-2009
    Location
    Taiwan
    MS-Off Ver
    Excel 2016,2019,O365
    Posts
    2,929

    Re: Ranking on cell value and getting number of unique value

    You are welcome.

+ 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