I'm trying to retrieve values from cells on the same row spaced 20 columns apart.
Right now I have put together the following formula to retrieve the values in the first five cells I am interested in:
={IF(OR(IF({1,2,3,4,5}*20+1<25,CHAR(MOD({1,2,3,4,5}*20+1,26)+64),CHAR(INT(({1,2,3,4,5}*20+1)/26)+64)&CHAR(MOD({1,2,3,4,5}*20+1,26)+64))&ROW()="OK"),"OK","N/G")}
The cells contain the results of calculation checks. The result if given as either "OK", "N/G" or "N/A". Right now I am interested in determining if even a single cell reports "OK", hence using the OR in the formula.
The problem is that whilst this gets the address of the cells correctly, they are returned as text. OR then does a text comparison on the addresses and the criteria and finds that none of the addresses are "OK"... which is logical, but not what I want.
I have tried using INDIRECT(), but that doesn't seem to work when it is in the form ={INDIRECT("A1","B2","C3")}. Could anybody suggest a way to change the text addresses to addresses which will correctly be interpreted by the formula?
I could write some vba code for this, but I'd like to use a formula solution if possible.
With a static stagger to the columns you want to examine, you can use MOD() to determine their ordinal position on the worksheet.
The formula in CE2 is =IF(SUMPRODUCT(($A2:$CC2=CE$1)*(MOD(COLUMN($A:$CC),20)=1)), "Yes", "No"). Fill right and down as necessary.
Related
I'm trying to count the number of distinct text from a specific date in a data table.
Data Sample with expect result :
I was able to figure out how to count the distinct element from a range I specify, because I can determine the first and last row containing the date.
=SUMPRODUCT(1/COUNTIF(B2:B15,B2:B15))
I have tried to modify my formula so that it determines the cell range by itself but without success.
I searched for an answer, using a combination of CELL and MAXIFS, example below, but Excel does not accept the formula.
=CELL("row",MAXIFS(A2:A15,A2:a15,D2))
I've looked at the INDEX formula, but I can't figure out how to do what I want to do. 😑
Any idea what I'm doing wrong, or what I should be doing instead?
Thanks, I appreciate it!
If you have Office 365 and the new Dynamic Arrays, this sort of formula has become ridiculously easy.
This formula in cell E3:
=COUNTA(UNIQUE(FILTER($B$2:$B$15,$A$2:$A$15=D3)))
Copy down.
You can also generate the unique list of dates with this formula in D3, which spills down automatically and does not need to be copied.
=UNIQUE(A2:A15)
It wasn't easy, but by separating each step of the problem, I was able to solve it.
Note that my solution only works because my dates are sorted.
Here's the final formula in the cell "One formula to rule them all":
=SUMPRODUCT(1/COUNTIF(INDIRECT(CONCATENATE(ADDRESS((MATCH(D3,$A$2:$A$15,0)+1),2),":",ADDRESS(MAX(($A$2:$A$15=D3)*ROW($A$2:$A$15)),2))),INDIRECT(CONCATENATE(ADDRESS((MATCH(D3,$A$2:$A$15,0)+1),2),":",ADDRESS(MAX(($A$2:$A$15=D3)*ROW($A$2:$A$15)),2)))))
Here are my explanations of my process:
Formula if I select the range :
=SUMPRODUCT(1/COUNTIF(B2:B15,B2:B15))
Formula to get the first iteration
=ADDRESS((MATCH(D3,$A$2:$A$15,0)+1),2)
Formula to get the last iteration
{=ADDRESS(MAX(($A$2:$A$15=D3)*ROW($A$2:$A$15)),2)}
Create range from two addresses
=INDIRECT(CONCATENATE(F3,":",G3))
Formula giving me the expect result
=SUMPRODUCT(1/COUNTIF(INDIRECT(CONCATENATE(F3,":",G3)),INDIRECT(CONCATENATE(F3,":",G3))))
I'm having a problem writing my formula that should count all selected cells that contain a number bigger than 0 and skip the cells that are completely empty, even when the cell is selected. Excel gives me an error that I selected cells that not contain a number. How can I skip them?
This is my formula:
=COUNTIFS(C8:C12;E8:E12;G8:G12;I8:I12;K8:K12;">0")
I'm thinking you using the COUNTIFS() formula wrong, after each range, there is a criteria. You can't have multiple ranges like that to look through. For more information look here or here.
In your case you are dealing with a non continues range, and one way to deal with that would be this
So the formula would translate to:
=SUM(COUNTIF(INDIRECT({"C8:C12","E8:E12","G8:G12","I8:I12","K8:K12"}),">0"))
Another formula you could try is:
=INDEX(FREQUENCY((C8:C12,E8:E12,G8:G12,I8:I12,K8:K12),0),2)
And looking at your data, it seems as though the rest of the columns contain text (not sure, they may be dates). In case they are text values:
=SUMPRODUCT((ISNUMBER(C8:K12))*(C8:K12>0))
If they are actually dates (assuming from 2018), then you could try:
=SUMPRODUCT((YEAR(C8:K12)<2018)*(C8:K12>0))
I'm assuming this is what you looking for, instead of a VBA based solution due to the tags provided and your formula.
You could also do it in this particular case by skipping the columns that you don't want:
=SUMPRODUCT((C8:I12>0)*ISEVEN(COLUMN(C8:I12)-COLUMN(C8)))
what will be happen if you use the below formula? to you receive an error?
=COUNTIF(C8:C12,">0")+COUNTIF(E8:E12,">0")+COUNTIF(G8:G12,">0")+COUNTIF(I8:I12,">0")+COUNTIF(K8:K12,">0")
Try this
Requirement cannot be done in single formula,
combining 2 or more formula will help fixing the formula.
formula
=COUNTA(B2:B9,D2:D9) -- Count all the non blank cell's
=COUNTIF(B2:B9,"=0")+COUNTIF(D2:D9,"=0") -- Count all the cells will value as 0
Subtract both which will give the output you are looking for
Combined formula
=COUNTA(B2:B9,D2:D9)-(COUNTIF(B2:B9,"=0")+COUNTIF(D2:D9,"=0"))
I am restructuring a few datasets and need to retrieve a list of non-contiguous values in a row in Excel for Mac. There are cells with blank spaces that should be discarded, so the result is a horizontal list of the same values, without the blank cells in between them.
The values appear in blocks of 6 contiguous cells interspersed by varying amounts (multiples of 6!) of blank cells. Data is numeric, so >0 does the trick. I have tried adapting solutions found online, such as this one here, with no luck.
I had to do something similar by retrieving 1st to 10th occurrence of values separately, and was able to accomplish that after dumping hloookup, learning index+match and array formulas, and adjusting solutions found online for a similar problem with columns, like this.
This is how my solution to the retrieving the 2nd occurence in a row looks like:
=IFERROR(INDEX($FR5:$GT5,SMALL(IF($FR5:$GT5>0,COLUMN($FR5:$GT5)-COLUMN($FR5)+1,FALSE),2)),"9999")
where $FR5:$GT5 is the range from which I need to retrieve values, and 9999 is my code for missing values. Just thought I'd throw it there, someone with limited skills as myself might find it useful.
Any tips to help me move along? Preferably, I'd like to adapt my previous formula to resolve this issue. I tried but was unable to get rid of the blank cells. I am stuck! Thanks in advance.
It isn't entirely clear on whether you want to show the collated (sans blanks) values in a row or a column but I suspect from the combination of relative row/absolute column cell references that you want to start in a cell and fill right.
Your formula is very close to collecting the sequence of numbers while ignoring blanks and numbers less than or equal to zero. You just need to adjust the k paramter of the SMALL function (the 2 in your sample formula above).
If you put =COLUMN(A:A) in a cell and fill right you will receive a sequence of integers like 1, 2, 3, 4, etc. Similarly, if you put =ROW(1:1) in a cell and fill down you will again receive 1, 2, 3, 4, etc. One of these sub-formulas can be used to increase the k of your SMALL depending upon whether you want to fill your formula right to receive the returned values in a single row or fill down to receive the returned values in a single column. In this manner, filling right or down will get you the second, third, etc returns.
To receive your returned values in a row use this array formula,
=IFERROR(INDEX(5:5, SMALL(IF($FR5:$GT5>0, COLUMN($FR:$GT)), COLUMN(A:A))),"9999")
Fill right as necessary to catch all values. To receive your returned values in a column use this array formula,
=IFERROR(INDEX($5:$5, SMALL(IF(FR$5:GT$5>0, COLUMN(FR:GT)), ROW(1:1))),"9999")
Fill down as necessary to catch all values.
Array formulas need to be finalized with Ctrl+Shift+Enter↵. Once entered into the first cell correctly, they can be filled or copied down or right just like any other formula.
I've never been a fan of the maths acrobatics (e.g. COLUMN($FR5:$GT5)-COLUMN($FR5)+1) that your original formula uses to determine the column (or row) in that style of formula. I've pared it down substantially in the above equivalent formulas but they amount to the same thing.
I am creating a work chart for a project with excel table. However with so many people to manage I have ran into an issue of often putting same person twice on different columns of the same row (he/she can't work on two places at same time!)
So, I am looking for help with a formula that notices if the same name appears twice on a row but does not count multiple blank cells as duplicates. My understanding of excel is very basic and so far I have managed to get this far
=COUNTIF(A6:W6;A6:W6)=1
which returns to me with false, which I assume is because of the blank, unfilled cells still within the table being counted as duplicates.
Help would be appreciated, thanks.
You can't have a range as the second argument of a Countif. The range you pass into the formula will resolve to just the first value. Use the Evaluate Formula tool to see what I mean.
If you want to determine if ANY name in the range A1:W1 appears more than once (and exclude blanks), you will need a recursive function. That can only be done with VBA, not with a formula.
You could use a Countif in a conditional format to highlight duplicate names in a row. That's a piece of cake. Pipe up if you want to do that.
I have a matrix setup where I am using multiple HLOOKUPS in a cell to derive a result. Due to some of the source data having blank cells, the HLOOKUP results in a #VALUE! error if any of the results lookup on a blank cell. I cannot use the IFERROR function because that will negate the addition and result in the entire formula deriving a blank result when in reality a summation of numbers should result (but because of the occurence of even one blank instance, the formula does not work). The way the spreadsheet is setup, I cannot change the source data to have zero in the blank cells, even though this would essentially solve the issue in a different way. Please see the example:
(HLOOKUP(L$1&"zzz.",Formula!$1:$34,$T5,FALSE)+HLOOKUP(L$1&"yyy",Formula!$1:$34,$T5,FALSE)+HLOOKUP(L$1&"uuu",Formula!$1:$34,$T5,FALSE)+HLOOKUP(L$1&"ppp",Formula!$1:$34,$T5,FALSE)+HLOOKUP(L$1&"ccc",Formula!$1:$34,$T5,FALSE)+HLOOKUP(L$1&"ddd",Formula!$1:$34,$T5,FALSE)
Any suggestions are greatly appreciated.
Your formula can be re-written in a different and more efficient way, viz:
=SUM(SUMIF(Formula!$1:$1,L$1&{"zzz.","yyy","uuu","ppp","ccc","ddd"},INDEX(Formula!$1:$34,$T5,)))
which also has the benefit that any search values which are not found do not cause the formula to error.
Even better would be to put those six search strings in the actual worksheet somewhere, e.g. A1:A6, in which case the above becomes the even-more succinct:
=SUMPRODUCT(SUMIF(Formula!$1:$1,L$1&$A$1:$A$6,INDEX(Formula!$1:$34,$T5,)))
Regards