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")
Related
I have a table with a target sum column (ColA) and three columns to filter based on criteria. I've been using SUMIFS to calculate the sum of ColA based on the criteria columns Cols B through D however I notice I'm not doing this correctly.
One thing to note is that the criteria columns have varying amounts of criteria each (e.g. column B has more OR conditions than C)
My current formula is:
SUM(SUMIFS(table[ColA], table[colB], {"val1", "val2", "val3"}, table[colC], {"val1", "val2"}, table[colD], {"val1", "val2", "val3", "val4"}))
The result of this formula is incorrect after manually checking the sum in the underlying table. Any advice on how to sum a column based on a set of multiple OR values?
You will need to do a SUMPRODUCT which will get long:
=SUMPRODUCT(table[ColA]*
((table[colB]="val1")+(table[colB]="val2")+(table[colB]="val3")>0)*
((table[colC]="val1")+(table[colC]="val2")>0)*
((table[colD]="val1")+(table[colD]="val2")+(table[colD]="val3")+(table[colD]="val4")>0))
To understand, the * is the equivalent to AND, the + is equivalent to OR
Let's say your table is called Table1, starts in A1 with headers, and is 4 columns wide. In a cell somewhere to the right, let's say G2, you could enter this formula:
=AND(OR(B2={"val1","val2","val3"}),OR(C2={"val1","val2"}),OR(D2={"val1","val2","val3","val4"}))
leaving G1 blank, then your sum formula is just:
=DSUM(Table1[#All],1,G1:G2)
You could also break the criteria formula up into three cells, one for each column, using:
=OR(B2={"val1","val2","val3"})
=OR(C2={"val1","val2"})
=OR(D2={"val1","val2","val3","val4"})
in G2:I2 (either leave G1:I1 blank, or give them labels that do not match any of your table headers), then use:
=DSUM(Table1[#All],1,G1:I2)
You could try to use MATCH() nested in SUMPRODUCT():
Formula in F1:
=SUMPRODUCT(ISNUMBER(MATCH(B2:B6,{"Val1","Val2","Val3"},0)+MATCH(C2:C6,{"Val1","Val2"},0)+MATCH(D2:D6,{"Val1","Val2","Val3","Val4"},0))*A2:A6)
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.
I'd like to know if there's a way to calculate two countifs with different data and criteria in a single formula (not row by row or with pivot tables). Let the following example apply:
I have the following table: fields A, B and C for each item (ID). Table header starts in cell T1.
I'd like to know how many items have 2 or more fields (A, B, C) with a number greater than 5.
I'd create another column X and use the following formula row by row: (Example for row 2)
=COUNTIF(U2:W2;">5")
and for that new column X (with all the COUNTIF formulas) I would use another COUNTIF
=COUNTIF(X:X;">1)
Is there a way to concatenate both? (I guess with an array formula)
Thanks in advance!
Try
=SUMPRODUCT((((U2:U11>5)+(V2:V11>5)+(W2:W11>5))>1)*1)
or
=SUMPRODUCT(--(((U2:U11>5)+(V2:V11>5)+(W2:W11>5))>1))
You can also use SUM(IF()) as an array formula like below
=SUM(IF(((U2:U11>5)+(V2:V11>5)+(W2:W11>5))>1, 1, 0))
Above being an array formula needs to be committed by pressing Ctrl+Shift+Enter.
I am referring to below my google spreadsheet
https://docs.google.com/spreadsheets/d/1dCfShenhV2j98q5wkOXMeyWj9tlMZbaBgBqB2vAPdHo/edit?usp=sharing
I am looking to update H,I and J columns using vlook formula in way that it should match both name and date values in my data range, which in A,B and C columns
Here is the issue I am facing with normal vlookup is that I can check only name.It is ignoring the date and updating the vlooked up data on all date column.
Eg: Alpha and date 20141120 value is 10, it should fill only H3, but it is updating, H3 I3 and J3 with value 10
I really appreciate your answer on this problem!!!
you can use this formula of index and match:
=IFERROR(INDEX($A:$C,MATCH(1,($A:$A=$G3)*($B:$B=H$2),0),3),"")
paste it in the first cell of your table H3, and drag and fill to the right and then select the entire row and fill down till end.
it should work.
if error(();"") : you will get empty cells if there is no match.
this is an array formula, so press ctrl+shift+enter to calculate the formula
UPDATE: here is [the example sheet downloadable from here}(https://www.dropbox.com/s/clqxsj5j4bdk27b/indexmatch.xlsx?dl=0)
Basically you need to concatenate the results, then use a VLOOKUP on that.
I.e. insert a column between B and C, with formula "=CONCATENATE(A2,B2)"
In the range you want to update, use the column and row headings for you lookup
"=VLOOKUP(CONCATENATE($g3,h$2),$c$1:$d$3,2,false)"
You want to perform a Multiple Lookup (see this).
As indicated there, enter
=IFERROR(LOOKUP(2,1/($A$1:$A$3=$G3)/($B$1:$B$3=H$2),$C$1:$C$3),"")
in H3. Copy into H3:J5.
This avoids array formulas.
Hi I'm a complete noob to excel and looking to do something like this:
For each item in column A
Get its corresponding value in column B and populate in column D
get its corresponding value in column C and populate in column E
the main problem I'm having is the number of rows in each column may differ.
I think I would need a macro to do this.
How could I do this in Excel?
If you don't want to resort to a macro and the presence of something in column A dictates when you want to see something in column D & E, then consider the following functions:
IsBlank( A1) returns true if A1 is empty else false.
If( condition, trueResult, falseResult) returns the corresponding result based on the condition.
So for example, you could write the formula for D1 to be:
=If( IsBlank(A1), "", B1 * 2)
would set D1 to be twice that of B1. You can now copy and paste that formula down the D column to as far as you need and because the formula uses relative addressing (B1 instead of $B$1) the formula is updated for each cell to work on the corresponding row.
If this doesn't solve your issue then more detail on your problem would be useful.