+ Reply to Thread
Results 1 to 30 of 30

Request for Excel formula for two conditions (Large to small, then small to large)

  1. #1
    Registered User
    Join Date
    08-10-2016
    Location
    singapore
    MS-Off Ver
    Microsoft® Excel® for Microsoft 365 MSO (Version 2411 Build 16.0.18227.20082) 64-bit
    Posts
    25

    Request for Excel formula for two conditions (Large to small, then small to large)

    Hi Experts,


    I need some help on the Excel formula.

    1 I need a formula for Column D (yellow)
    2 The first condition is Risk Exposure (Column B) should rank from largest to smallest.
    3 The second condition is Management Preparedness (Column C) should rank from smallest to largest
    4 The result should be as follows:

    Ranking Risk Risk Exposure Management Prepardness Ranking
    1 C1 3.2 1.6 C1
    2 C4 3.2 1.6 C4
    3 C5 2.5 3 C5
    4 C2 2.3 5 C2
    5 C3 1.4 3 C3
    Attached Files Attached Files

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Request for Excel formula for two conditions (Large to small, then small to large)

    In E4 Cell - Helper Column

    =IFERROR(LARGE($B$4:$B$8,ROWS($1:1)),"")


    In D4 Cell - Array Formula - Requires CTRL+SHIFT+ENTER

    =INDEX($A$4:$A$8,SMALL(IF($B$4:$B$8=E4,ROW($C$4:$C$8)-MIN(ROW($C$4:$C$8))+1),COUNTIF($E$4:E4,E4)))

    Array formulas need to be entered using the key combination of CTRL,SHIFT,ENTER (not just ENTER). Hold down both the CTRL key and the SHIFT key then hit ENTER.


    Drag both the formula's down

    Refer the attached file.
    Attached Files Attached Files


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Request for Excel formula for two conditions (Large to small, then small to large)

    Assuming that the raw data starts in the format shown in the screen capture included in your sample, a formula will not sort the original data for you.

    A formula can be used to show the data sorted as required in a different column, but the order of the original data will be unchanged.

    Also could you elaborate more on your comment in the sample:

    I need a formula instead of using sort button because I have many entity to manipulate the data.

  4. #4
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,784

    Re: Request for Excel formula for two conditions (Large to small, then small to large)

    As I see I have misunderstood the OP's problem I'm deleting my comment to this post.

    Alf
    Last edited by Alf; 08-13-2016 at 04:10 AM. Reason: Did not fully understand OP's request

  5. #5
    Registered User
    Join Date
    08-10-2016
    Location
    singapore
    MS-Off Ver
    Microsoft® Excel® for Microsoft 365 MSO (Version 2411 Build 16.0.18227.20082) 64-bit
    Posts
    25

    Re: Request for Excel formula for two conditions (Large to small, then small to large)

    Thanks Sixthsense (Forum Guru) for the help. However, I think didn't clearly saying my problem here. I have many entities to rank the risks. Some of the entities may not have the certain risk, so the cell would reflect as N/A. Basically whatever Forum Guru (Sixth sense) explained is correct. Just i didnt mention my risk conditions. Hope you all can help me ...Really appreciate....Help from Singapore.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    08-10-2016
    Location
    singapore
    MS-Off Ver
    Microsoft® Excel® for Microsoft 365 MSO (Version 2411 Build 16.0.18227.20082) 64-bit
    Posts
    25

    Re: Request for Excel formula for two conditions (Large to small, then small to large)

    Thanks all for the prompt response...I really appreciate your help. Hope you all can help me to solve this problem...

  7. #7
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,784

    Re: Request for Excel formula for two conditions (Large to small, then small to large)

    As you got two kind of sorting (Risk Exp and management preparedness) and I assume you wish the C ranking sett accordingly for every group so I've added
    a macro solution as well.

    Alf
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    08-10-2016
    Location
    singapore
    MS-Off Ver
    Microsoft® Excel® for Microsoft 365 MSO (Version 2411 Build 16.0.18227.20082) 64-bit
    Posts
    25

    Re: Request for Excel formula for two conditions (Large to small, then small to large)

    Thanks ALF for the solutions. However, I am just an Excel beginner so i would appreciate using the formula.. I am not good at Macro...But your Marco results are correct. Hope you all can help me with the formula.....Thanks alot......Help from Singapore

  9. #9
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: Request for Excel formula for two conditions (Large to small, then small to large)

    In D2, then drag down.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by kvsrinivasamurthy; 08-13-2016 at 06:21 AM.

  10. #10
    Valued Forum Contributor
    Join Date
    06-21-2013
    Location
    Bangladesh
    MS-Off Ver
    Excel 2000, Excel XP, Excel 2002, Excel 2007, Excel 2010, Excel 2013
    Posts
    975

    Re: Request for Excel formula for two conditions (Large to small, then small to large)

    Dear forum admins, I don't know how to delete a post here. I want to delete this post. Can you show me the way to do this?
    Last edited by sanram; 08-13-2016 at 06:57 AM. Reason: Want to delete this post

  11. #11
    Valued Forum Contributor
    Join Date
    06-21-2013
    Location
    Bangladesh
    MS-Off Ver
    Excel 2000, Excel XP, Excel 2002, Excel 2007, Excel 2010, Excel 2013
    Posts
    975

    Re: Request for Excel formula for two conditions (Large to small, then small to large)

    Sorry. I missed your last post. So please ignore my previous post and use this :

    Please Login or Register  to view this content.
    Last edited by sanram; 08-13-2016 at 06:58 AM.

  12. #12
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Request for Excel formula for two conditions (Large to small, then small to large)

    Quote Originally Posted by nicholascky View Post
    I am just an Excel beginner so i would appreciate using the formula.. I am not good at Macro
    A 'macro' in this case is probably this simplest option, you don't need to be good with them to use them, as long as you are capable of clicking a mouse button then you are good to go.

  13. #13
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: Request for Excel formula for two conditions (Large to small, then small to large)

    ARRAY formula in E5, then drag down
    Please Login or Register  to view this content.
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    08-10-2016
    Location
    singapore
    MS-Off Ver
    Microsoft® Excel® for Microsoft 365 MSO (Version 2411 Build 16.0.18227.20082) 64-bit
    Posts
    25

    Re: Request for Excel formula for two conditions (Large to small, then small to large)

    To Sixthsense, jason.b75, Alf, kvsrinivasamurthy and Sanram,

    Appreciate your help!!!! I have solved the problem.

  15. #15
    Registered User
    Join Date
    08-10-2016
    Location
    singapore
    MS-Off Ver
    Microsoft® Excel® for Microsoft 365 MSO (Version 2411 Build 16.0.18227.20082) 64-bit
    Posts
    25

    Re: Request for Excel formula for two conditions (Large to small, then small to large)

    Hi Expert,

    There is still some error in the attached worksheet. The ranking of risk should first rank the risk exposure from the largest to lowest, then management preparedness should rank from lowest to largest.
    Attached Files Attached Files

  16. #16
    Registered User
    Join Date
    08-10-2016
    Location
    singapore
    MS-Off Ver
    Microsoft® Excel® for Microsoft 365 MSO (Version 2411 Build 16.0.18227.20082) 64-bit
    Posts
    25

    Re: Request for Excel formula for two conditions (Large to small, then small to large)

    Actually, would it be possible to rank the risk by risk identification instead of number, like C4, C6, C7?

  17. #17
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Request for Excel formula for two conditions (Large to small, then small to large)

    I haven't looked at the most recent example, this is based on Sheet2 of the sample file that you provided in post #5.

    Helper formula, to be entered into F5

    =COUNTIF($C$5:$C$57,">"&IFERROR(C5,0))+IF(ISNA(D5),0,COUNTIFS($C$5:$C$57,C5,$D$5:$D$57,">"&D5))+COUNTIFS(C$4:C4,C5,D$4:D4,D5)+1

    Formula to return risk ID to be entered into E5

    =INDEX($B$5:$B$57,MATCH(ROWS(E$5:E5),$F$5:$F$57,0))

    On the assumption that it might be your next question, the formula cannot copy the colour formatting of the risk ID's from column B.

    If it is done with conditional formatting, then you can apply the same rules to the formula cells.

    Cell formats changed manually can only be copied by macro, there is no formula that is capable of doing it.

  18. #18
    Valued Forum Contributor
    Join Date
    06-21-2013
    Location
    Bangladesh
    MS-Off Ver
    Excel 2000, Excel XP, Excel 2002, Excel 2007, Excel 2010, Excel 2013
    Posts
    975

    Re: Request for Excel formula for two conditions (Large to small, then small to large)

    As of your post I have prepared your file with 2 helper column which is resulting exactly as you want. Hope that it may help.


    Logically ranking the risk with risk identification instead of number will never be possible. Because you will not be able to know the ranking from risk identification anyhow. So, I am not clear about that requirements.

    But if you want to place a letter before the ranking then you can do this with custom format as I have done on the sample.
    Attached Files Attached Files

  19. #19
    Registered User
    Join Date
    08-10-2016
    Location
    singapore
    MS-Off Ver
    Microsoft® Excel® for Microsoft 365 MSO (Version 2411 Build 16.0.18227.20082) 64-bit
    Posts
    25

    Re: Request for Excel formula for two conditions (Large to small, then small to large)

    Hi Excel Experts,

    There are still have some errors appear in the ranking. (#N/A)

    My requirements are as follows:

    Ranking of risk should be sort by Risk Exposure (Largest to Smallest), then by Management Preparedness (Smallest to Largest).

    The ideal situation would be in the attached Sheet 2 using the sort function.

    Appreciate your advice.!!
    Attached Files Attached Files

  20. #20
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Request for Excel formula for two conditions (Large to small, then small to large)

    Quote Originally Posted by nicholascky View Post
    There are still have some errors appear in the ranking. (#N/A)
    I can't see anything in your thread that tells us how you wanted #N/A to be ranked, so we had to guess.

    Looking at your latest sample I assume that you want #N/A at the top, in which case, please follow post #17 (the new formula is based on the same sample file, not the most recent one), replacing the first formula with this one.

    =COUNTIFS($C$5:$C$57,">"&IFERROR(C5,1E+100))+IF(ISNA(D5),0,COUNTIF($C$5:$C$57,"#N/A")+COUNTIFS($C$5:$C$57,C5,$D$5:$D$57,">"&D5))+COUNTIFS(C$4:C4,C5,D$4:D4,D5)+1

  21. #21
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: Request for Excel formula for two conditions (Large to small, then small to large)

    Pl see file and mark where results are not tallying.
    Attached Files Attached Files
    Last edited by kvsrinivasamurthy; 08-14-2016 at 02:22 AM.

  22. #22
    Registered User
    Join Date
    08-10-2016
    Location
    singapore
    MS-Off Ver
    Microsoft® Excel® for Microsoft 365 MSO (Version 2411 Build 16.0.18227.20082) 64-bit
    Posts
    25

    Re: Request for Excel formula for two conditions (Large to small, then small to large)

    Hi All Subject Matter Experts,

    Thanks for your support and solution. It really solved my problem...Do i need close the thread?

  23. #23
    Registered User
    Join Date
    08-10-2016
    Location
    singapore
    MS-Off Ver
    Microsoft® Excel® for Microsoft 365 MSO (Version 2411 Build 16.0.18227.20082) 64-bit
    Posts
    25

    Re: Request for Excel formula for two conditions (Large to small, then small to large)

    Will buy you all dinner when any of you come to Singapore. Hahaha

  24. #24
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: Request for Excel formula for two conditions (Large to small, then small to large)

    May I know which solution is OK.

  25. #25
    Registered User
    Join Date
    08-10-2016
    Location
    singapore
    MS-Off Ver
    Microsoft® Excel® for Microsoft 365 MSO (Version 2411 Build 16.0.18227.20082) 64-bit
    Posts
    25

    Re: Request for Excel formula for two conditions (Large to small, then small to large)

    The solution given by kvsrinivasamurthy. Thanks alot...Thanks other contributors as well...The members here are very helpful and supportive.

  26. #26
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Request for Excel formula for two conditions (Large to small, then small to large)

    I still fail to see how that matches what you asked for, the order of the results looks nothing like the example you provided.

    This looks closer to what you asked for, unless your example was wrong.
    Attached Files Attached Files

  27. #27
    Registered User
    Join Date
    08-10-2016
    Location
    singapore
    MS-Off Ver
    Microsoft® Excel® for Microsoft 365 MSO (Version 2411 Build 16.0.18227.20082) 64-bit
    Posts
    25

    Re: Request for Excel formula for two conditions (Large to small, then small to large)

    Maybe I didn't articulate my requirements clearly in the beginning and also I am just a beginner. Some forum experts here might provided the correct solution but I didn't how to apply it.

    But kvsrinivasamurthy (Excel expert) was giving me the most direct formula that i wanted. Anyway, thanks for you all.

  28. #28
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Request for Excel formula for two conditions (Large to small, then small to large)

    Quote Originally Posted by nicholascky View Post
    Some forum experts here might provided the correct solution but I didn't how to apply it.
    Then maybe it is time to learn.

    If you discard the suggestions that people provide simply because you don't understand how to use them, then those people will be less likely to help you next time you need it.

  29. #29
    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. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,375

    Re: Request for Excel formula for two conditions (Large to small, then small to large)

    Quote Originally Posted by nicholascky View Post
    But kvsrinivasamurthy (Excel expert) was giving me the most direct formula that i wanted. Anyway, thanks for you all.
    Jason is also a Forum Expert, and as he said, you need to learn from the advice given.
    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.

  30. #30
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: Request for Excel formula for two conditions (Large to small, then small to large)

    Thanks for the feed back.

+ 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. Replies: 5
    Last Post: 07-19-2015, 11:05 AM
  2. [SOLVED] Excel only shows small fraction of rows in large file
    By Devourer in forum Excel General
    Replies: 3
    Last Post: 06-26-2013, 09:40 AM
  3. Formula issue with LARGE and SMALL
    By Pearlyn in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 04-30-2013, 03:16 AM
  4. Replies: 6
    Last Post: 09-27-2012, 10:45 AM
  5. Replies: 0
    Last Post: 01-10-2012, 01:15 PM
  6. Large, Small, Index, Match formula combos
    By taudano in forum Excel General
    Replies: 2
    Last Post: 06-30-2011, 01:53 AM
  7. Excel size getiing very large on small change
    By ballack in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-18-2007, 02:38 AM

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