I have a question regarding COUNTIFS. The simple boiled down version of what I am trying to do is this:
I am trying to use COUNTIFS to count the number of entries that the cell in a column is either blank or in the future (greater than today) and that is marked with an “X” in another column.
There are several other renditions in the formula but if I can get this, I can get the rest. So far, I have this:
=SUM(COUNTIFS($C$2:$C$50,{"";">"&TODAY()},$E$2:$E$50,"X"))
Excel won’t let me return out of the formula and highlights the quotation mark following the greater than symbol.
=SUM(COUNTIFS($C$2:$C$50,{"";">100"},$E$2:$E$50,"X")) works fine when I play around and test things but when I try to add in &TODAY() or reference a cell, things go sideways.
Any suggestions as to what I am doing wrong? The actual formula is quite long and there are several comparisons that are made between columns. I've seen some references to using SUMPRODUCT but haven't been able to figure it out that way either.
You can use a formula to generate the criteria array, i.e.
=SUMPRODUCT(COUNTIFS($C$2:$C$50,IF({1;0},"",">"&TODAY()),$E$2:$E$50,"X"))
I used SUMPRODUCT in this version because with SUM you'd need CTRL+SHIFT+ENTER
The IF function generates an array that resolves to something like this:
{"";">43060"}
Related
I would like to identify which rows don't have consecutive data. For this, I'd like to be able to count the cells across rows until and empty cell is encountered.
Please look at the the screenshot of an example and desired output.
I have tried to play around with the MATCH function, but no look yet. I've tried the following but it's not returning what I would've expect.
{=MATCH(FALSE,ISBLANK(C2:F2),0)}
You may try in this way however there might be a more eloquent way to solve this,
So the formula used in cell G2
=IF(MAX(FREQUENCY(IF(C2:F2,COLUMN(C2:F2)),
IF(C2:F2=FALSE,COLUMN(C2:F2))))<3,"Jumps A Year",
MAX(FREQUENCY(IF(C2:F2,COLUMN(C2:F2)),
IF(C2:F2=FALSE,COLUMN(C2:F2)))))
And Fill Down!
Also note, depending on your excel version you may or may need to press CTRL+SHIFT+ENTER, not just ENTER after entering the formula. You will know the array is active when you see curly braces { } appear around your formula.
I have multiple values in one cell that are ordered like this:
0#0#54232#5#123# ...
Now I want to put every single value in a separate cell. I tried working with SEARCH, FIND, LEFT, MID functions and so on, but everthing looks so fiddly and I can't get it to work. My idea was to look for every # in the text and get every substring in between. But with 20+ values in a single cell this gets very confusing by the end.
EDIT: The lengths of the values can vary
You can use FILTERXML to split the string (this solution will work on Office 365, since dynamic arrays need to be available):
=FILTERXML("<t><s>"&SUBSTITUTE(A1;"#";"</s><s>")&"</s></t>";"//s[string-length()>0]")
There has recently been a nice question here on Stackoverflow that I highly recommend to read:
Excel - Extract substring(s) from string using FILTERXML
You can use following formula (also in older excel versions):
=IFERROR(FILTERXML("<t><s>"&SUBSTITUTE($A$1;"#";"</s><s>")&"</s></t>";"//s["&ROW()&"]");"")
I've put your string in cell B3, and in cell C2, I've put following formula:
=LEFT(B3;FIND.SPEC("#";B3)-1)
In cell C3, I've put following formula:
=SUBSTITUTE(B3;C2&"#";"";1)
I've been dragging the whole thing to the right, and row 2 gave me the results you are looking for. (You might need to add some IfBlank() or IfError() but you understand what I mean)
I am trying to build a rank formula that ignores errors.
I've tried:
=Rank(BN4,(if(iserror(BQ4:BQ31),"",BQ4:BQ31)))
I've also Tried:
=IF(ISERROR($BQ$4:$BQ$31),"",1+SUMPRODUCT($BP$4:$BP$31=BP4,$BQ$4:$BQ$31>BQ4))
Is There something wrong with the formula? Is there a better way? See image below, the rank formula appears in Col BN. Thanks!
]1
Given the spreadsheet below:
You can use the following formula on C2 and drag it:
=IF(ISERR(A2),"",COUNTIF($A$2:$A$7,">"&A2)+1)
I think this is what's going on: in your second formula, your Sumproduct is still calculated with the errors. Although the first part your formula tells Excel to return a Blank when calculating the rank of an ERROR, the errors are stil inputted into second part where you actually calculate the rank, and thus Excel will spit out an Error even if it's calculating the rank of a regular number
The formula provided by Lucas above is probably the simplest way. If you must use sumproduct, you should include something in your sumproduct that tells excel to use a blank value if it comes across an error when calculating the some product.
For example, if you're trying to do the sumproduct of A1:A4 and B1:4 but the both ranges have some errors, then you'd use:
=SUMPRODUCT(IF(ISNA(A1:A4),0,A1:A4),IF(ISNA(B1:B4),0,B1:B4))
I am trying to produce a count of the number of times different strings come up in an Excel table. An example table, currently in SHEET1, would be this:
I have another table in another spreadsheet where I want to indicate, for each letter on the left in Table 1, how many entries for "za", "zc" or "zd" come up on the right. However, I would only like to only consider one entry of each.
The end result, on row B of SHEET2, would have to be something like this:
At the moment I am using a combination of SUM and COUNTIFS to do the job.
More specifically, applied to the example, I am using the following formula:
=SUM(COUNTIFS(Sheet1!A1:A18,Sheet2!$A1,Sheet1!B1:B18,{"za","zc","zd"}))
The formula is doing some of what is intended. However, it is not counting each entry just one time. Instead, its is counting, for each letter on the left, every entry of "za","zc" or "zd". The table that the formula is returning is as follows:
How can I change the formula so that it does what I intend?
Thank you.
My initial thought would be:
=SUM(MIN (1,COUNTIFS(Sheet1!A1:A18,Sheet2!$A1,Sheet1!B1:B18,{"za","zc","zd"}))
but I’m not where I can test if the MIN will apply properly to the COUNTIFS array of results. ;-)
EDITED: The MIN function is taking minimum of 1 or all of the items in the COUNTIFS array, rather than minimum of 1 and each item in the COUNTIFS array, which is what I was afraid of. Using
=MIN(COUNTIFS(Sheet1!A$1:A$18,Sheet2!$A1,Sheet1!B$1:B$18,"za"),1)+MIN(COUNTIFS(Sheet1!A$1:A$18,Sheet2!$A1,Sheet1!B$1:B$18,"zc"),1)+MIN(COUNTIFS(Sheet1!A$1:A$18,Sheet2!$A1,Sheet1!B$1:B$18,"zd"),1)
will gain the desired results. It is a little clunky, but simpler than an array formula. If you want an array formula, you can use:
=SUM(FREQUENCY(IFERROR(MATCH({"za","zc","zd"},(IF(Sheet1!$A$1:$A$18=$A5,Sheet1!$B$1:$B$18)),0),""),IFERROR(MATCH({"za","zc","zd"},(IF(Sheet1!$A$1:$A$18=$A5,Sheet1!$B$1:$B$18)),0),"")))
This uses the FREQUENCY function to take a set of values and see how many items in another set of values fall within each of the data ranges. Since you need text instead of numbers, we use the MATCH function to find out the first time the value occurs in your list, returning "" with the IFERROR function if it doesn't. (We only need the first occurrence since you don't want to know how many occurrences there are). Since it is text, we use the same input for both arguments for FREQUENCY.
Therefore, if you need to change the values you are looking for or the ranges in which you are searching, make sure to change both! Alternately, you could list the values out somewhere, say in F1:F3, and make a named range for this, another one for A1:A18, and another for B1:B18. Your formula would then look something like this:
=SUM(FREQUENCY(IFERROR(MATCH(SearchValues,(IF(colA=$A2,colB)),0),""),IFERROR(MATCH(SearchValues,(IF(colA=$A2,colB)),0),"")))
Then you need only change your named range definitions and your formulas would update. :-)
NOTE: Since this is an array formula, you must close out of the cell by pressing CTRL+SHIFT+ENTER rather than only ENTER. When you look at the formula bar, you should see
{=SUM(FREQUENCY(IFERROR(MATCH(SearchValues,(IF(colA=$A2,colB)),0),""),IFERROR(MATCH(SearchValues,(IF(colA=$A2,colB)),0),"")))}
It does NOT work to enter the curly braces yourself. ;-)
You can use this formula at B1 and fill down:
B1:
=SUMPRODUCT(((Sheet1!$A$1:$A$18=A1)*(Sheet1!$B$1:$B$18= {"za","zc","zd"}))/
COUNTIFS(Sheet1!$A$1:$A$18,Sheet1!$A$1:$A$18,Sheet1!$B$1:$B$18,Sheet1!$B$1:$B$18))
I have to put together a weekly reporting system in Excel. I need to report on the month to dale sales results and the completed week (Fri-Thu). This is collected from multiple sales agents in sales documents stored in Sharepoint.
For this, I've used "SUMIFS" to collect the data, the following way:
=SUMIFS('SHAREPOINTREF/FILE.xlsm'!SalesResults[One off],'SHAREPOINTREF/FILE.xlsm'!SalesResults[Date],">="&B7,'SHAREPOINTREF/FILE.xlsm'!SalesResults[Date],"<="&C7)
(B7 is a cell reference which determines the start date of the week, with C7 being the end of the week)
The trouble with SUMIFS, as well as SUMIF, COUNTBLANK, COUNTIF and COUNTIFS, is that they don't work when the sourcing document is closed. Microsoft has a workaround here: https://support.microsoft.com/kb/260415?wa=wsignin1.0
I can't seem to figure out how to adapt the workaround methodology recommended to apply not just to a simple IF statement, but to multiples. I assume I would need to use an "AND" statement, but I keep getting errors when I'm trying.
I have about half a dozen different calculations to make, but I am pretty confident if I can solve this one, the others should start to gel a bit better.
Try this:
=SUM(IF('SHAREPOINTREF/FILE.xlsm'!SalesResults[Date]>=B7,IF('SHAREPOINTREF/FILE.xlsm'!SalesResults[Date]<=C7,'SHAREPOINTREF/FILE.xlsm'!SalesResults[One off])))
Entered using Ctrl+Shift+Enter.
Non-Array formula equivalent:
=SUMPRODUCT(--('SHAREPOINTREF/FILE.xlsm'!SalesResults[Date]>=B7),--('SHAREPOINTREF/FILE.xlsm'!SalesResults[Date]<=C7),'SHAREPOINTREF/FILE.xlsm'!SalesResults[One off])
But both seems to return #REF! when source WB is closed even though the link provided in the question claims otherwise.
Edit1:
After more digging, above will work but you need to use a Normal Range and not a Table Range.
The only problem is, you loose the advantage of Table's Dynamic Data Range.
So something like this will work even if the source is closed:
=SUMPRODUCT(--('SHAREPOINTREF/[FILE.xlsm]Sheet1'!$A$2:$A$11>=B7),--('SHAREPOINTREF/[FILE.xlsm]Sheet1'!$A$2:$A$11<=C7),'SHAREPOINTREF/[FILE.xlsm]Sheet1'!$B$2:$B$11)
The recommended solution is to use array formulas. Those are a special type of formula that, when typed, must be activated by pressing Ctrl + Shift + Enter in the formula bar. Such a function works by applying a function that would normally accept a single cell (such as IF() ) to a range. You will need to wrap the result in an aggregating formula such as SUM() or COUNT(). Here's an example:
=SUM(IF($A$1:$A$10="Apple", $B$1:$B$10, 0))
This formula would check each cell from A1 to A10 and compare it to "Apple", if it is true it will return the corresponding row from $B$1:$B$10. The result would be an array of values of column B where column A is "Apples" with zeros where it is not. The surrounding SUM() aggregates the array and gives the equivalent of SUMIF().
As I mentioned, you would need to enter Ctrl + Shift + Enter after typing the formula for it to work as an array formula. Otherwise, it will work as a regular formula.