+ Reply to Thread
Results 1 to 12 of 12

Combinations to ignore blanks (combination match issue based on random variables)

  1. #1
    Registered User
    Join Date
    08-12-2020
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    6

    Combinations to ignore blanks (combination match issue based on random variables)

    I am trying to solve combination query, based on specific criteria
    Issue #
    #1. The formula in Cell C15, is to choose random number based on Criteria A in cell P4 and W4, For example in (Table 1)if Cell "P4" (value A) = Column "W" (value A) give me a random value from Table B in this instance the values are (3,5), my question ~ is it possible to change values in the below formula highlighted in bold automatically, meaning instead of (1,2,3,4,5) give me only (3,5) and ignore blank cells (note these are not static numbers, they will change based on the sets below in "green", hence they need to be dynamic).

    The same formula will apply to rest of the cells to be dynamic. I have been trying this and have asked quite a few people and no one has the solution, I am hoping to find an answer here. I hope the above explanation is clear, in case my apologies, please ask me to reiterate the question, I will do so. Thank you in advance

    =IF(P4=$W$4,CHOOSE(RANDBETWEEN(1,COUNTIF($C$4:$M$11,$W$4)),B]1,2,3,4,5[/B]),IF(P4=$W$5,CHOOSE(RANDBETWEEN(1,COUNTIF($C$4:$M$11,$W$5)),6,7,8,9,10,11),IF(P4=$W$6,CHOOSE(RANDBETWEEN(1,COUNTIF($C$4:$M$11,$W$6)),12,13,14,15,16),IF(P4=$W$7,CHOOSE(RANDBETWEEN(1,COUNTIF($C$4:$M$11,$W$7)),17,18,19,20,21,22),IF(P4=$W$8,CHOOSE(RANDBETWEEN(1,COUNTIF($C$4:$M$11,$W$8)),23,24,25,26,27),IF(P4=$W$9,CHOOSE(RANDBETWEEN(1,COUNTIF($C$4:$M$11,$W$9)),28,29,30,31,32,33),IF(P4=$W$10,CHOOSE(RANDBETWEEN(1,COUNTIF($C$4:$M$11,$W$10)),34,35,36,37,38),IF(P4=$W$11,CHOOSE(RANDBETWEEN(1,COUNTIF($C$4:$M$11,$W$11)),39,40,41,42,43,44),0))))))))

    I also have #NUM error and duplication of numbers in the same row issue (highlighted in gold) which is the later part of the query.

    Thank you in advance.
    Attached Files Attached Files

  2. #2
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Combinations to ignore blanks (combination match issue based on random variables)

    I'll be honest and say I'm struggling to follow it, and I think the duplicate piece will make more complex etc but, in terms of the basic ask, the below:

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    would generate an INDEX of valid #s, e.g. {3;5} for C15/P4, {15;16;17} for D15/Q4 etc, and the RANDBETWEEN would pick a random item from that array of numbers

    hopefully that helps (a little) but, I suspect, I have misunderstood
    Last edited by XLent; 08-12-2020 at 06:53 AM. Reason: typo in narrative

  3. #3
    Registered User
    Join Date
    08-12-2020
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    6

    Re: Combinations to ignore blanks (combination match issue based on random variables)

    Thank so much Xlent, you have been a great help. I guess Column A:A needs to be fixes correct, if I drag the formula?

    #2. Duplication - I wanted to avoid duplicates value in the same row
    #3. Is there a fix for #NUM error, is it possible to have any other number from the list that is not duplicated in place of #NUM error

    I know this is quite complicated, however I cannot thank you enough for your help thus far.

  4. #4
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Combinations to ignore blanks (combination match issue based on random variables)

    I guess Column A:A needs to be fixes correct, if I drag the formula?
    the A:A and A$1 references can be left as-is -- these are just being used (w/ROW) to build a dynamic array of 1 to n, to be used as k-array within the AGGREGATE call -- i.e. these references are completely agnostic of your data.

    #2. Duplication - I wanted to avoid duplicates value in the same row
    if I've understood, I think the below would address that?

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    the above, as it is copied across, removes from the 'possible' array any # already used and, adjusts the boundary of the RANDBETWEEN accordingly
    so, in other words, the 2nd instance of a given condition in a row would see the upper threshold of the RANDBETWEEN reduced by 1 to account for fact one number must already be assigned, and which has been removed from the array

    #3. Is there a fix for #NUM error, is it possible to have any other number from the list that is not duplicated in place of #NUM error
    this one you might need to elaborate on, I'm afraid.
    Would limiting the "any" number to those assigned to conditions NOT in use on that row work? using "any" unused number (irrespective of whether or not the condition is active on the row) is significantly more complicated

    on a final aside, I would advise removing your CF rules on that matrix and replacing with one single rule -- with C15 the active cell, apply a CF rule (with same format) of:

    =(COUNTIF($C15:$H15,C15)>1)

    and apply to C15:H64

  5. #5
    Registered User
    Join Date
    08-12-2020
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    6

    Re: Combinations to ignore blanks (combination match issue based on random variables)

    Thank You Xlent, for your prompt reply, I have attached the file with the second formula, still there are duplicates, not sure If I have done it right?

    Third - #NUM error, I am not sure if I follow correctly, I guess I will have to sort them out and use the one's with no errors. However if the duplicates are sorted, I guess I have achieved a milestone with your generous help.
    Attached Files Attached Files

  6. #6
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Combinations to ignore blanks (combination match issue based on random variables)

    so, the formula in my prior post should be pasted into C15 (note: not an Array), and then copied across the matrix C15:H64 -- without modification.
    at that point, all dupes should disappear bar the #NUM!

    re: #NUM! -- what I'm saying is, these will only appear where you have fewer available numbers (re: AB:AC) than the times a condition is being used on a row

    I believe you want to assign a number to these, rather than #NUM!, so I'm suggesting you isolate the numbers (re: AB:AC) that are assigned to condition codes that you are not referencing in that particular row

    Consider: 3 instances of "E" in Cols F:H and an "F" in Col C
    if you don't restrict which numbers to use as an alternate for "F" (given it has none in AB:AC) you could, theoretically, assign one of the # assigned to "E" thus rendering the last "E" bereft of it's own number...
    so, to avoid the recursive nature, it would be simplest to say - for #NUM! I cannot use any number that belongs to a condition that I am referencing on this row... as they must be ring-fenced

    Hope that makes sense.

  7. #7
    Registered User
    Join Date
    08-12-2020
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    6

    Re: Combinations to ignore blanks (combination match issue based on random variables)

    Thank you once again, I have attached as you mentioned I have copied and pasted C15:H64 without any modifications, still duplicates are there, are you able to attach a version 3 of this file with the formula, please?

    Re #NUM - I got What you mean, I should replace the Alphabets that are missing, that's perfect I can do that. Thank you for being patient.
    Attached Files Attached Files

  8. #8
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Combinations to ignore blanks (combination match issue based on random variables)

    See if the attached version does what you need -- inclusive of the #NUM! logic (assigns first available) -- note I've not been able to really spot check results so will need you to post back with anomalies etc.

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    there are some other changes in here, from previous iteration, to try and accommodate both valid/invalid scenarios, but also to simplify - a little.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    08-12-2020
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    6

    Re: Combinations to ignore blanks (combination match issue based on random variables)

    You are simply genius, thank you so much! Please let me know if I could be of any help in return.

  10. #10
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Combinations to ignore blanks (combination match issue based on random variables)

    You're welcome -- there are probably more elegant approaches but glad it worked.

    In terms of help -- well, boards such as this need contributors - so if you see some questions you can help with, get stuck in...

  11. #11
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Combinations to ignore blanks (combination match issue based on random variables)

    Not sure if I get this right.

    Please try at C15

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

  12. #12
    Registered User
    Join Date
    08-12-2020
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    6

    Re: Combinations to ignore blanks (combination match issue based on random variables)

    Sorry for the delay in my reply. Yes, the formula works and much simpler too.

    Like Xlent said there may be more elegant approaches, which is what I think you delivered.

    Thank you so much!

+ 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. Select random value from array but ignore blanks
    By green214 in forum Excel General
    Replies: 13
    Last Post: 04-08-2020, 06:05 PM
  2. Help needed! INDEX/MATCH, Ignore Blanks in an array
    By JavierEM in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-31-2019, 10:05 PM
  3. [SOLVED] Ignore blanks in Index/Match
    By dazbear in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-25-2018, 03:55 PM
  4. Getting INDEX MATCH MATCH to ignore blanks
    By JK_Nation in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 12-08-2016, 05:44 PM
  5. Search Through a Column to Find Match, ignore blanks return Value
    By lmc2016 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-13-2016, 11:39 AM
  6. How to ignore blanks in an Index/Match Array Formula
    By michaelcarrera in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-06-2015, 08:50 PM
  7. Index Match Combination for two variables
    By zhopa19 in forum Excel General
    Replies: 2
    Last Post: 06-21-2011, 03:07 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