How to cope with more than 100 IF statements - excel

I am creating an checklist using an array of checkboxes in MS Excel 2007. Based on the number of checkboxes, there are 2^7 (=128) possible combinations in which the checkboxes can be selected. Each combination of checkboxes selected gives a unique outcome.
What would be the most efficient way to successfully test for each condition, and give a result in a cell in a worksheet?
Example code:
=if(and(chkbox1=true,chkbox2=true,chkbox3=false,chkbox4=false,chkbox5=true,chkbox6=false,chkbox7=true),"Unique outcome",if(and(chkbox8=true,chkbox9.............)))))))))
The method I have (unsuccessfully) attempted is to use IF statements. I have attempted to bypass the nested IF limit by creating 14 named ranges with approximately nine nested IFs each, and compile the 14 named ranges in a valid nested IF within the spreadsheet. Unfortunately, the processor is struggling to calculate the outcome of this (i.e. computer is "freezing").
Would reducing the number of nested IFs in the named ranges (but increasing the number of nested IFs in the spreadsheet) have an influence on efficiency?
Would it be better to use nested IFs in cells rather than named ranges?
Would VLOOKUP work?
At the moment, I am contemplating using VBA code as people have said that it would be the most efficient way to approach numerous conditions. Does anyone have any suggestions or recommendations?

String together a 1 or 0 for each TRUE or FALSE result then create a lookup table with a column for each possible binary value and another column for the outcomes (or rows rather than columns).

To expand on pnuts's answer, you could achieve this with a formula such as:
=if(chkbox1=true,1,0)+if(chkbox2=true,2,0)+if(chkbox3=true,4,0)+if(chkbox4=true,8,0)+ ...
This will give you a value between 0 and 127 which you can then use in a VLOOKUP function to get the appropriate result from a two column table (or more simply, in an OFFSET function to get the appropriate result from a single column list).

Related

Excel dynamic filter array

Hello my dear excel friends!
My "List" table consists of 10 columns that I filter by needed criterias in the second tab, which works perfectly. Now I have problems with the following filtering:
Cell B7 = Name
Cell B8:F8 = Items 1-5
Cell B9:F8 should be the order number (different amount for each item) of the respected items in the cells above.
Depending on the Name the items are spilling differently without any problems with
=IFERROR(TRANSPOSE(UNIQUE(FILTER(List[Item];(List[Name]=$B$7))));"")
Now I want to spill out the order numbers for each item in each column. The amount of orders can differ depending on the column. Unfortunately for now I can do it only for one column and have to copy the function to the next column:
=IFERROR(UNIQUE(FILTER(List[Order];(List[Item]=B8)*(List[Name]=$B$7)));"")
I have tried to do it with IFS but could not achieve the needed results. I can imagine something like B9# but somehow can not implement it into my function. Is there a way to do it?
Very difficult to give a rigorous solution for such a case. The following is convoluted though should work for smallish ranges:
=LET(μ,List[Item],κ,List[Name],η,B7:B11,ρ,MAX(COUNTIF(κ,η)),λ,TRIM(MID(FILTERXML("<a><b>"&TEXTJOIN(REPT(CHAR(32),50),,IFERROR(IF(INDEX(TRANSPOSE(κ),SEQUENCE(,ROWS(κ)+1))=η,TRANSPOSE(μ),""),"</b><b>"))&"</b></a>","//b"),SEQUENCE(,ρ,1,50),50)),IFERROR(INDEX(λ,SEQUENCE(ROWS(η)),SEQUENCE(,ρ)),""))
I've assumed that B7:B11 is your list of names. Amend as required.
In my opinion a non-spill formula to be copied down is preferable.

Return location of duplicate values from multiple sheets in excel

I am looking for a simpler formula to identify on which sheet duplicates occur on multiple sheets. I have been able to achieve this with a formula:
=IF(COUNTIF(RDFR!$T$5:$T$10;global_data!$T8);"RDFR"&IF(COUNTIF(RDIT!$T$5:$T$10;global_data!$T8);"RDIT"&IF(COUNTIF(RDSE!$T$5:$T$10;global_data!$T8);"RDSE";""))) - but if the data is not found in one of the sheets it results in "False", I wish to return the two names of sheets where it does actually duplicate yet still look across all sheets simultaneously. If this is not possible my solution is to create the IF(COUNTIF(...in multiple combinations making the formula very large. I have a total of 10 worksheets where 9 need to be compared to the first.
I have also been able to do this with an extra long multiple IF and vlookup function. But, I am again needing to repeat the equation too many times.
If I understand correctly, you want something like this:
=CHOOSE(
{1;2;3},
IF(COUNTIF(RDFR!$T$5:$T$10,global_data!$T8),"RDFR",""),
IF(COUNTIF(RDIT!$T$5:$T$10,global_data!$T8),"RDIT",""),
IF(COUNTIF(RDSE!$T$5:$T$10,global_data!$T8),"RDSE","")
)
It will return a spill formula of 3 cells with either the sheet name, or a null string.
If you want to remove the null strings, use the filter function.

Return Array of SUMPRODUCT Results

I am trying to merge the contents of tables, rank them, and return the results as an array so that, eventually, values can be found with INDEX or VLOOKUP. I'm on a work network. I am stuck with Excel 2013 without PowerQuery and macros are a hard no. I am trying to avoid hidden sheets and helper columns. I have managed to successfully combine the output of tables into a single array, but am having trouble accomplishing getting a ranking of each item into an array.
Here is the sample workbook I'm using to do a proof of concept:
https://1drv.ms/x/s!AmnV99KYATO-g5kxvJBpTSSjF_XBXw
Everything is currently on just one sheet, but the goal is to eventually link tables from multiple sheets or even workbooks together and have the results automatically aggregated in a table that is both sortable and filterable. I'm trying to end the endless Ctrl+C and Ctrl+V I currently do to aggregate data.
For readability, most of the formulas in the workbook have been turned into named arrays. I have the last few steps broken out so you can see where I am stuck. The components of the named array RANKED only return a single digit, not an array of 24 values like the COMBINED formula. When I Ctrl+Shift+Enter my final RANKED array I get the expected result, but when I do VLOOKUP and INDEX I get errors because RANK only returns one value. You can see in the table on the right VLOOKUP fails after the first row.
I am using SUMPRODUCT instead of COUNTIF because (as far as I know) COUNTIF cannot take arrays as input. There is then an offset so that the ranking works like RANK.EQ. Does anyone know how to accomplish what I am trying to do or am I attempting the impossible?

I am having trouble with an excel formula

I am trying to come up with a formula in excel that allows me to have two separate criteria from two separate lists and then sum the total amount of values that meet those criteria. I can get the set of criteria to work, so
=COUNTIFS(Data!A:A,[#[Sub ID]] section allows me to see the amount of times a specific supID appears in column A. However, the second part where I am trying to see after that how many times any value from a particular list of values appears in a separate list, does not work.
Is there any way to make a formula count one list of values against another list of values without having to name each additional value in the formula.
I could do this if I wrote,
=SUM(COUNTIFS(Data!A:A,[#[Sub ID]],Data!B:B,{"=apples","=pears","=bananas"[....]}))
But I don't want to have to write out each additional value, the list is too long. I just want to have the list in a column so I can reference it in the equation but it wont let me.
=SUM(COUNTIFS(Data!A:A,[#[Sub ID]],Data!B:B,Mapping2!B:B))
You are creating an iterative formula, You want to limit the last criterion to just the data set:
Mapping2!B2:B15
Then use SUMPRODUCT which will force the iteration:
=SUMPRODUCT(COUNTIFS(Data!A:A,[#[Sub ID]],Data!B:B,Mapping2!B2:B15))

Cross table comparisons, sumproduct

I am trying to compare two different Excel (2010/xlsx) tables with related data to find matches. They would be on different sheets but in the same workbook (not that it should affect the problem).
I think the best route is some combination of sumproduct, match, and index... but I haven't been able to get them to work so far. I see the main question (cell G17) being solved by creating a subset of rows from Table 2 to compare against their corresponding data in Table 1 (index/match), then using arrays to do a multiple criteria selection to count how many match the criteria I chose (sumproduct).
I have played around with vlookup, countif(s), and sumif(s) but haven't seen a good way to apply them to this problem.
You can use SUMIF as a "quasi-lookup" like this
=SUMPRODUCT((file="doc")*(modified < SUMIF(user,creator,create)))
I'm not sure how to do it in a single cell as you've asked, but I would create an extra column in the second table which uses vlookup to find the created date, and another column containing whether or not the created date is greater than the modified date. Finally, you could use countif to combine them.
To be more concrete, in your example, I would put =vlookup(F3,A$3:D$5,2,FALSE) in cell I3, and =I3>H3 into cell J3, and expand both of these down. Then cell G17 could be given by =countif(J3:J5,TRUE).

Resources