I have a table with many values as such (this is an oversimplified example):
IDx
Namex
Pricex
1
a
5
2
b
2
1
a2
5
3
c
3
2
b2
9
and another table with only the ID, in which I'd like to add a column that shows the addition of all the values that match that ID, in this example:
IDy
Totaly
1
10
2
11
3
3
I'm guessing this is a combination of vlookup with sum or sumif, I've tried so far:
=SUM(VLOOKUP(IDy1,$IDx$1:$IDx$5,$Pricex$1:$Pricex$5),// don't know how to proceed here
Try this:
B5:B9 = IDx
B16,D5 = Price
=SUMIF(B$5:B$9,B16,D$5:D$9)
Related
I'm trying to use the following max function by the group in column A. The value I want in C is the max entry of each group in column B. When column B is normal numbers, this function works. However, I would like column B to be populated by the results of a different function (in this case an =IF function that successfully returns a number). When I do this, I get 0's.
in column C: =MAX(IF($A$2:$A$5=C2,$B$2:$B$5))
Column A
Column B
Column C
Group 1
5
5
Group 1
4
5
Group 2
6
7
Group 2
7
7
Column A
Column B
Column C
Group 1
=IF(...)
0
Group 1
=IF(...)
0
Group 2
=IF(...)
0
Group 2
=IF(...)
0
Any idea what could be going on? Please let me know if I can provide anything additional to help explain.
Thank you!
Reese
I'm trying to use Excle's SUMIF to calculate totals of Col1 to Col5 for dates that are similar.
My formula is as follows =SUMIF($A2:$A7,A10,$B2:$F7), but this only gives me the total of a single column.
How can I get the Totals of all the columns based on the date like I've shown in my results.
Date Col 1 Col 2 Col 3 Col 4 Col 5
1/5/2017 1 2 2
1/5/2017 5 3 1
1/5/2017 9 5 5
2/5/2017 10 5 3
2/5/2017 20 10 3
2/5/2017 6 8 1 5
Desired Results
1/5/2017 15 7 7 3 1
2/5/2017 30 11 11 11 8
use below formula in cell B11
=SUMIF($A$2:$A$7,$A11,B$2:B$7)
Per the example you provided, One solution is to use SUMPRODUCT
Multiplies corresponding components in the given arrays, and returns the sum of those products
Microsoft Docs give a thorough example, but per SO etiquette, here is an example in case of link-rot: [FYI, I used absolute reference for easier filling across, arbitrary how you get it done though]
Forumlas shown:
Formula is kind of hard to see without clicking on image:
=SUMPRODUCT(($B$3:$B$8=$B$11)*C3:C8)
This basically breaks down like this, it searches the B:B column for a match, and it will naturally return a true or false for the match, or 0/1 counterparts, and multiplys that by the number found in the column to the right (C3:C8), so it will either be 1 * # = # or 0 * # = 0
I have a table array that looks like this:
A B
1 2
1 3
1 9
2 3
2 4
2 11
2 23
2 56
3 7
4 13
My VLOOKUP formula is to check for 1 in column A and then return the corresponding B value. Is there anyway I can get all the values for 1? Currently it just returns back the last corresponding number for 1 i.e. 9 in column B.
You can Pivot that data, or you can try INDEX and MATCH together, perhaps even an IF command with it.
I'm looking for a formula calculating : distinct Count + multiple criteria
Countifs() does it but do not includes distinct count...
Here is an example.
I have a table on which I want to count the number of distinct items (column item) satisfying multiple conditions one column A and B : A>2 and B<5.
Image description here
Line Item ColA ColB
1 QQQ 3 4
2 QQQ 3 3
3 QQQ 5 4
4 TTT 4 4
5 TTT 2 3
6 TTT 0 1
7 XXX 1 2
8 XXX 5 3
9 zzz 1 9
Countifs works this way : COUNTIFS([ColumnA], criteria A, [ColumnB], criteria B)
COUNTIFS([ColumnA], > 2 , [ColumnB], < 5)
Returns : lines 1,2,4,5,8 => Count = 5
How can I add a distinct count function based on the Item Column ? :
lines 1,2 are on a unique item QQQ
lines 4,5 are on a unique item TTT
Line 8 is on a unique item XXX
Returns Count = 3
How can I count 3 ?!
Thanks
You can download the excel file # Excel file
Newer versions of Excel allow for this problem to be solved in a (relatively) more simple way. It certainly is easier to follow and understand, conceptually.
First, filter the table based on multiple criteria (join multiple with the *):
=FILTER(Table,(Table[Column A]>2)*(Table[Column B]<5))
Then, grab the "Item" column with INDEX:
=INDEX(FILTER(Table,(Table[Column A]>2)*(Table[Column B]<5)),,2)
Next, filter for unique entries:
=UNIQUE(INDEX(FILTER(Table,(Table[Column A]>2)*(Table[Column B]<5)),,2))
Finally, perform a count:
=COUNTA(UNIQUE(INDEX(FILTER(Table,(Table[Column A]>2)*(Table[Column B]<5)),,2)))
Ugly formula, but it works.
=SUM(((FREQUENCY(IF(C2:C10>2,1,0)*IF(D2:D10<5,1,0)*(COUNTIF(B2:B10,">"&B2:B10)+1),ROW(B2:B10)-ROW(B2)))*(ROW(B2:B11)-ROW(B2))>0)*1)
I'll start with the criteria IFS:
IF(C2:C10>2,1,0)*IF(D2:D10<5,1,0)
Gives an array of 1s and 0s for the rows that satisfy both criteria. ARRAY = {1;1;1;1;0;0;0;1;0} for your example.
Where B2:B10 is the Item column, the countif formula:
COUNTIF(B2:B10,">"&B2:B10)
returns {6;6;6;3;3;3;1;1;0} where the number equals the number of item values in B2:B10 alphabetically less than the tested item value.
QQQ goes to 6 [3"TTT", 2"XXX", 1"zzz"]
TTT goes to 3 [2"XXX", 1"zzz"]
XXX goes to 1 [1"zzz"]
zzz goes to 0 [0 less than "zzz"]
Need to add 1 to this array to make sure there are no 0 values:
{7;7;7;4;4;4;2;2;1}.
So when multiplying the criteria, and the countif statement:
(IF(C2:C10>2,1,0)*IF(D2:D10<5,1,0)*(COUNTIF(B2:B10,">"&B2:B10)+1)
You get ARRAY = {7;7;7;4;0;0;0;2;0}.
FREQUENCY(ARRAY,ROW(B2:B10)-ROW(B2))
ROW(B2:B10)-ROW(B2) sets the frequency bins to {0;1;2;3;4;5;6;7;8}. So the output of the frequency formula is {4;0;1;0;1;0;0;3;0;0} where the last 0 is for all values greater than 8.
((ROW(B2:B11)-ROW(B2)>0)*1) equals {0;1;1;1;1;1;1;1;1;1}. Multiplying ARRAY by this removes the 0 count at the start: ARRAY = {0;0;1;0;1;0;0;3;0;0}. [NOTE: B11 is lowest item column cell+1 because of the added array value from the frequency formula for values over 8]
(ARRAY)>0)*1 = {0;0;1;0;1;0;0;1;0;0}
SUM this = 3.
ctrl + shift + enter, because it's an array formula.
cmd + shift + enter for mac.
You could try this:
=SUMPRODUCT(1/COUNTIF(B2:B10,B2:B10))
Credit where credit due, however ... I found it over here:
https://exceljet.net/formula/count-unique-values-in-a-range-with-countif
I'm looking for a way to find the first specific value above a certain cell.
Using the example below, in the result column every time I hit a A in COL2, I need to substract the value in COL1 to the first A value above.
The trouble seems finding a way to keep the range dynamic...
I thought of =IF(B5="A";A5-INDIRECT("A"&MATCH("A";B:B;0));"")
But of course that only works for the first one as Match will always pick up the first one.
Any ideas? Thanks!
Example :
COL1 COL2 Result
1 A
2 0
3 0
4 A 4 - 1 = 3
5 0
6 A 6 - 4 = 2
7 0
8 0
9 0
10 A 10 - 6 = 4
Try this:
=IF(AND(ROW(B2)<>2,B2="A"),A2-INDEX($A$1:$A1,AGGREGATE(14,6,ROW($1:1)/($B$1:$B1="A"),1)),"")
The AGGREGATE() Function was introduced in 2010.
In D2 enter =IF(B2="A",A2-INDIRECT("A"&MATCH("A"&(E2-1),F:F,0)),"")
In E2 enter =IF(B2="a",COUNTIFS($B$2:B2,"a"),"")
In F2 enter =B2&E2
Copy formulas from D, E and F down all your rows
Column D is the result you're looking for