+ Reply to Thread
Results 1 to 17 of 17

Formula to return the most commonly occurring (text) value based on criteria

  1. #1
    Registered User
    Join Date
    03-10-2021
    Location
    England
    MS-Off Ver
    2013
    Posts
    26

    Formula to return the most commonly occurring (text) value based on criteria

    Hello experts,

    I am wondering if you can help me (again).

    I am trying to create a formula to automate some values in a table. I have an idea in my head, but if you have any better ideas, please feel free to share - as I still learning.

    I have 2 data sets -

    1 - List of Sites
    2 - List of Issues (Exceptions) recorded for each site.

    Please see sample provided.

    I would like to use the List of Sites to form a table whereby the most commonly occurring reason for each category automatically populates. After some research online it suggests using Index, Match and Mode functions - but I am not clever enough to create that on my own - so am hoping you guys may be able to help me out.

    Many thanks in advance.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365
    Posts
    3,187

    Re: Formula to return the most commonly occurring (text) value based on criteria

    Hi,
    please see attached, if I understood you correct then -

    D4 and across:
    ="The most commonly occuring exception reason for issues pertaining to"&" "&D$3&"at site"&" "&""""&TRIM($C4)&""""&" (IF ANY)"
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    03-10-2021
    Location
    England
    MS-Off Ver
    2013
    Posts
    26

    Re: Formula to return the most commonly occurring (text) value based on criteria

    Thank you for the reply, but sadly it was not what I was looking for. My Output sheet was just to describe what I was looking for. I want the actual reasons from the exceptions tab to appear in the table and not just the text that I wrote. The text I wrote was just to explain what I wanted to go where. Thanks, though.

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

    Re: Formula to return the most commonly occurring (text) value based on criteria

    What result do you want if there are 2 or more criteria with equal counts?

    And if needed, is a VBA solution OK?

  5. #5
    Registered User
    Join Date
    03-10-2021
    Location
    England
    MS-Off Ver
    2013
    Posts
    26

    Re: Formula to return the most commonly occurring (text) value based on criteria

    Hi, John. Good question - both(or all) results if possible. I don't think it would be that common where two 'Reasons' share the same count but definitely a consideration.

    VBA is not something I know much about, or anything about to be honest, so formula would definitely be the preferred option. But if VBA is the only way, that may have to do. Just a couple of questions around that if VBA is the solution -

    1. Would I just need to run a macro to complete that table?
    2. If so, I assume it wouldn't take too long to update?
    3. Is there a way I can run the VBA, update the table, and then just disable so I can send this sheet out on a weekly basis without other users having to run it?

    Many thanks for your input. Appreciated.

    P.s. this is only a method I have thought up in my head. There may be a better way of doing it. I just want to so for each site, the most common reason for each determinant (Turbidity, Ammonia etc).

  6. #6
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Formula to return the most commonly occurring (text) value based on criteria

    to answer your questions, is the sample a sample or is it a comparable size to the real file you use?

    probably
    1)yes
    2) depends on its size, see above
    3) Yes or you send it out as a sperate sheet/workbook where they can not change anything, this could be part of the VBA code

  7. #7
    Registered User
    Join Date
    03-10-2021
    Location
    England
    MS-Off Ver
    2013
    Posts
    26

    Re: Formula to return the most commonly occurring (text) value based on criteria

    It's comparable. Usually 2.5-4k rows. Not much variation weekly. Never vastly more than that.

  8. #8
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Formula to return the most commonly occurring (text) value based on criteria

    what about the attached pivot as a starting point

    Chooses the top 1 option for each category
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    03-10-2021
    Location
    England
    MS-Off Ver
    2013
    Posts
    26

    Re: Formula to return the most commonly occurring (text) value based on criteria

    That pivot is exactly right, and was my first choice. I want to be able to show a simple bar chart with the site > determinants > most common reason. However, when I chart it, it's completely messy because of the multiple columns. So my second choice was to go for the table I asked for above.

    Attachment 729570

    I have tried reformatting and googling for advice but nothing I do makes the chart look how I want it too.

  10. #10
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Formula to return the most commonly occurring (text) value based on criteria

    but you can base the table on the pivot. I am at a loss how you can bar chart text values!
    https://www.contextures.com/excelloo...ndexmatch.html to populate your table

  11. #11
    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,906

    Re: Formula to return the most commonly occurring (text) value based on criteria

    In D4 of "Output Idea")

    =IFERROR(INDEX(Sheet1!$C$4:$C$90,MATCH(1,('Output Idea'!$C4=Sheet1!$A$4:$A$90)*('Output Idea'!D$3=Sheet1!$B$4:$B$90),0)),"")

    Enter with Ctrl+Shift+Enter

    Copy across and down

    Based Davsth pivot table BUT you require "Exception Reason" not "Exception Category"
    Last edited by JohnTopley; 04-23-2021 at 09:13 AM.

  12. #12
    Registered User
    Join Date
    03-10-2021
    Location
    England
    MS-Off Ver
    2013
    Posts
    26

    Re: Formula to return the most commonly occurring (text) value based on criteria

    Fantastic!

    Thank you both. This is a relief. I appreciate you both taking the time to help me out.

    Quick question - the source data will change on a weekly basis, which will of course amend the pivot table, too. Is there a way I can force the formula to adjust it's range that it's looking up. (There will be a varying number of sites each week - between 40-60). Or will it do this automatically?

    Thanks again.

  13. #13
    Registered User
    Join Date
    03-10-2021
    Location
    England
    MS-Off Ver
    2013
    Posts
    26

    Re: Formula to return the most commonly occurring (text) value based on criteria

    Also, just out of curiosity if I can just ask - how did you manage to formulate the return of the highest number/most common reason? I can't work it out in your formula. I.e. where Turbidity has 5/6 reasons, what part of the forumla is making it return only the highest value?

    Thanks again.

  14. #14
    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,906

    Re: Formula to return the most commonly occurring (text) value based on criteria

    My formula simple takes the results of the Pivot Table and puts them in your output matrix.

    As noted previously the Pivot table returns Category rather than Reason so it needs amending: not an area I am familiar with.

    If the pivot table is in the same sheet, I assume you can make dynamic range(s)..

  15. #15
    Registered User
    Join Date
    03-10-2021
    Location
    England
    MS-Off Ver
    2013
    Posts
    26

    Re: Formula to return the most commonly occurring (text) value based on criteria

    Yes that's fine I have already amended the pivot and everything is working fine. I just couldn't work out how it knows to take the largest count from the list - but either way it's doing it nicely.

  16. #16
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Formula to return the most commonly occurring (text) value based on criteria

    In the filter for the exception field value filters top 10 (stupidly named), if you select it you can choose top 1Attachment 729598

  17. #17
    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,906

    Re: Formula to return the most commonly occurring (text) value based on criteria

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

+ 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. [SOLVED] Formula to return text based on two criteria
    By KClem in forum Excel General
    Replies: 6
    Last Post: 10-16-2017, 02:16 PM
  2. [SOLVED] How Can I: Display the Most Commonly Occurring Word in a Block of Text?
    By Sandcastle in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 06-23-2015, 10:00 AM
  3. [SOLVED] Is this possible?? Find most commonly occurring words in a cell
    By lukesmith7 in forum Excel General
    Replies: 6
    Last Post: 08-28-2014, 11:59 AM
  4. Display most commonly occurring text, IF text occurs more than X times
    By Kpolly in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-04-2014, 02:24 PM
  5. Replies: 5
    Last Post: 10-17-2013, 08:03 PM
  6. [SOLVED] Formula to return specific text based on multiple cells meeting a single criteria
    By missydanni in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-13-2013, 09:48 AM
  7. Return most frequently occurring text in row
    By penfold in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-13-2011, 12:38 PM

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