(excel) Using COUNTIFS with OR - excel-formula

I hope that someone can offer a solution to the following formula.
=SUM(COUNTIFS(Table2[ColumnA],$AE$16,Table2[ColumnC],$A18,Table2[Date1],"<"&Table2[Date2],Table2[Date2],BLANK))
I want a count of matching values but for the last 2 I want to be an OR instead of what is presently there which I assume operates as an AND.
Specifically count if Date1 is less than Date2 or if Date2 is a Blank cell.
Thanks in advance.

If you use a additional column it will work easily:
Column A & B have your data, column C contain x if data2 is empty or > for comparision. Formula in column C is =IF(B2="","x",IF(A2>B2,">","")). Your result is delivered in cell E2 with formula =COUNTIF(C:C,"=?")
Formulas are translated from german Excel, i hope they will work fine.

Related

Excel formula - column changes based on result of another column

I would like to know how to change the column of a formula based on the result of another formula:
I have two columns:
Column Letter
Transaction Count
A
=countif(sheet1!$A$1:$$5, "Apple")
B
=countif(sheet1!$B$1:$B$5, "Apple")
C
...
DY
As opposed to having to copying the present formula and changing the range manually, is there a formula so that I can quickly populate C to DY? Thank you for your help.
One way would be to use INDIRECT.
=COUNTIF(INDIRECT(SUBSTITUTE("Sheet1!$#$1:$#$5", "#", A1)), "Apple")

Excel function for SUMIF (RIGHT = RIGHT)?

It's probably a quick one, but I'm desperate...
How can I put 2 corresponding RIGHT functions into a SUMIF? Or does this need VBA?
The case:
I want the sum of B:B, if any cell of J:J has the same last 4 numbers as A1.
EDIT
Column J shows the date an invoice was payed (e.g. "14. November 2020"). A1 is the headline and includes "Income 2020".
The sum in B14 should show how much money came in in the year the sheet is representing.
SUMIF(RIGHT(J:J;4);RIGHT(A1;4);B:B)
May someone enlighten me?
Thanks a lot!
Thomas
If column J contains true dates, then you can use SUMIFS and DATE:
=SUMIFS(B:B;J:J;">="&DATE(RIGHT($A$1;4);1;1);J:J;"<="&DATE(RIGHT($A$1;4);12;31))
This isn't working because the value in column J is a date. You should use SUMIFS and use a date range.
=SUMIFS(B:B,J:J,">="&DATE(RIGHT(A1,4),1,1),B:B,"<="&DATE(RIGHT(A1,4),12,31))

excel SUMIFS only on same date

I'm trying to create a formula in column K which sums all cells that apply , in column J, only when the following conditions are true:
dates are the same in column A
AND client name is the same in column B
For example, in cell K2, I want the sum of J2+J3+J4 because A2=A3=A4 and B2=B3=B4.
K5=J5 only, because there are no other dates with the same client name.
K6=J6+J7 because A6=A7 and B6=B7.
What kind of formula would I use for this? I can't figure out how to do it with a SUMIFS.
I would try using a pivot table with:
The names as row values
The dates as the column values
And funds received using SUM in the values column
Edit
Based on #pnuts comments here is how to get the values in column K. Put this in K2 and drag down.
=IF(OR(COUNTIFS($B$1:B3, B3) = 1, B3 = ""), SUMIFS($J$2:J2, $A$2:A2, A2, $B$2:B2, B2), "")
This formula will give blank values until the formula finds a new client on a new date. However, I still think using pivot table is a better solution.
However, I still find the pivot table
In cell K2 put following formula:
=IF(COUNTIFS($A$2:A2,A2,$B$2:B2,B2)=1,SUMIFS($J$2:$J$10,$A$2:$A$10,A2,$B$2:$B$10,B2),"")
Adjust row 10 value. It will be last row of your actual data.
Copy down as much you need.
EDIT
Uploaded file shows the cause behind formula not working correctly for you. It turned out to be whitespace characters in column B (names) data e.g.
Cell B3: "Moe John" has a trailing space.
Cell B10: Same case with "Doe Jane"
If you want to use above posted formula then all names shall be corrected. Or alternatively to deal with spaces you can adopt below approach.
=IF(COUNTIFS($A$2:A2,A2,$B$2:B2,"*"&TRIM(B2)&"*")=1,SUMIFS($J$2:$J$28,$A$2:$A$28,A2,$B$2:$B$28,B2),"")
Notice the change in COUNTIFS formula where B2 is now replaced with "*"&TRIM(B2)&"*".
Even such formula will take a beating if you have uneven whitespace characters in between your data. I'd suggest normalizing it as much as possible.

excel formula to add cells in a single row based on criteria

Let's say,
Sheet1:A1 = x
Sheet2 contents look like
x 3 3 4
y 0 2 1
Is there an excel formula that could match Sheet1:A1 with Sheet2:A1 (basically the value 'x') and add the other cells in that row (3,3,4). The result (Sum='10') should get updated at Sheet1:C4 lets say.
I tried SUMIF but that shows the content of only one column due to the restriction that it can handle only the matchable array size. I know this can be achieved through VBA, but just wanted to know if a formula is available.
TIA!
This formula will do what you want:
=SUM(SUMIF(Sheet2!A:A,A1,INDIRECT("Sheet2!" & {"B:B","C:C","D:D"})))
It will iterate through the columns doing individual SUMIF() on each and then adding the results.
If you want more columns or different change the address in the array to the columns desired.
Try the following
=SUM(IF(Sheet2!A1:A99=A1,Sheet2!B1:D99,0))
Note that this is an array formula, so it must be entered using Ctrl+Shift+Enter.
What this formula does is converts any rows on Sheet2 without x in column A to zeros in B:D and then sums what is left.
Similarly, you could use
=SUMPRODUCT((Sheet2!A1:A99=A1)*Sheet2!B1:D99)
and you wouldn't have to enter it as an array formula.
For a non-volatile, non-array formula, try this
=SUM(INDEX(Sheet2!B:D,MATCH(Sheet1!A1,Sheet2!A:A,0),))

A formula in Excel to count the number of rows where there is a date in column 'K' but column 'N' is blank?

I am a little rusty to say the least and in Excel I would like to create a formula that counts the number of cases that have been closed without a certain stage taking place.
So, the formula would need to count the number of rows where there is a date in column k, but no date in column n (the cell is blank). Any help would be appreciated. I have had a go with COUNTIFS and SUMPRODUCT but I'm not getting anywhere.
Try this
=COUNTIFS(K:K,">0",N:N,"")
that's counting rows where K is greater than zero but N is blank [""]
If you can use another column try this formula, for every row of the column:
=IF(K1>0,1,0)*IF(N1="";1;0)
then you have to sum column values.
Instead of K1>0 you can use two cell for date so you can count cells within a range of date.
For a start try something like:
=SUMPRODUCT((K1:K100<>"")*(N1:N100=""))

Resources