+ Reply to Thread
Results 1 to 24 of 24

Ranking on cell value and getting number of unique value

Hybrid View

Navin Agrawal Ranking on cell value and... 07-15-2024, 01:51 AM
AliGW Re:... 07-15-2024, 02:17 AM
Navin Agrawal Re:... 07-15-2024, 02:50 AM
AliGW Re: Ranking on cell value and... 07-15-2024, 02:19 AM
JohnTopley Re: Ranking on cell value and... 07-15-2024, 02:37 AM
Navin Agrawal Re: Ranking on cell value and... 07-15-2024, 03:25 AM
JohnTopley Re: Ranking on cell value and... 07-15-2024, 03:45 AM
Navin Agrawal Re: Ranking on cell value and... 07-15-2024, 05:45 AM
AliGW Re: Ranking on cell value and... 07-15-2024, 03:15 AM
windknife Re: Ranking on cell value and... 07-15-2024, 04:17 AM
Navin Agrawal Re: Ranking on cell value and... 07-15-2024, 05:46 AM
JohnTopley Re: Ranking on cell value and... 07-15-2024, 06:05 AM
windknife Re: Ranking on cell value and... 07-15-2024, 06:11 AM
Navin Agrawal Re: Ranking on cell value and... 07-15-2024, 10:40 PM
Navin Agrawal Re: Ranking on cell value and... 07-16-2024, 01:45 AM
windknife Re: Ranking on cell value and... 07-16-2024, 01:51 AM
Navin Agrawal Re: Ranking on cell value and... 07-16-2024, 03:43 AM
windknife Re: Ranking on cell value and... 07-15-2024, 10:45 PM
AliGW Re: Ranking on cell value and... 07-16-2024, 01:51 AM
Navin Agrawal Re: Ranking on cell value and... 07-16-2024, 02:30 AM
AliGW Re: Ranking on cell value and... 07-16-2024, 02:46 AM
windknife Re: Ranking on cell value and... 07-16-2024, 04:57 AM
  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,015

    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 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

  4. #4
    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,015

    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.

  5. #5
    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,883

    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

    =SUM(1/COUNTIF(industry1,industry1))[/FORMULA]

    points1

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

    in I3

    Formula: copy to clipboard
    =RANK(G3,Points1,0)


    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.

  6. #6
    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.

  7. #7
    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,883

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

    in D1

    Formula: copy to clipboard
    =SUM(1/COUNTIF(OFFSET($D$3,,,$E$1),OFFSET($D$3,,,$E$1)))


    in I3

    Formula: copy to clipboard
    =RANK($G$3,OFFSET($G$3,,,$E$1))

  8. #8
    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

  9. #9
    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,015

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

    Please respond to post #4.

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

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

    D1 committed with Ctrl+Shift+Enter
    =SUM(IF($D$3:$D100="",0,1/COUNTIF($D$3:$D$100,$D$3:$D$100)))
    I3 copied down.
    =IF(G3="","",COUNTIF($G$3:G100,">="&G3))

  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,883

    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,928

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

    Try this in I3.

    =IF(G3="","",COUNTIF($G$3:G100,">"&G3)+COUNTIF($G$3:G3,G3))

  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 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.

    =IF(G3="","",COUNTIF($G$3:G100,">"&G3)+COUNTIF($G$3:G3,G3))
    @windknife: If I may bother you?

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

    Many thanks

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

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

    How about this?
    =IF(--G3=0,"",COUNTIFS($G$3:G$100,">"&G3,$G$3:$G$100,"<>0")+COUNTIF($G$3:G3,G3))

  17. #17
    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?
    =IF(--G3=0,"",COUNTIFS($G$3:G$100,">"&G3,$G$3:$G$100,"<>0")+COUNTIF($G$3:G3,G3))
    @windknife

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

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

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

    B2
    =if(--a2=0,"",countifs(a$2:a$200,">"&a2,a$2:a$200,"<>0")+countif(a$2:a2,a2))
    Attached Files Attached Files

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

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

    You are welcome.

  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,015

    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))

  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

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

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

  22. #22
    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,015

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

    You're welcome.

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

    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