Excel to sum value of duplicates while retaining its duplicate text - excel

I need help on a loooong list of values that is possibly having duplicates with its quantity needed to sum however while retaining its duplicates.
Hard to explain, example of scenario and goal I'd like to achieve.
Please help.
Current Situation
material value
a 10
b 10
a 10
c 10
c 10
a 10
b 10
b 10
b 10
Goal to Achieve
material value
a 30
b 40
a 30
c 20
c 20
a 30
b 40
b 40
b 40
Something like above. I'm jumbled up with the formulas. Please help!

One important point to consider here: First, because you need to sum values AND change the values you're summing, you're going to get a circular reference if you try to do this dynamically.
One way to get around this is to add a third column, with the formula =SUMIF(A:A,A1,B:B)
If you absolutely need the values in column B, just copy from C, then paste the values, or just hide column B.

Related

Sum values using lookup table, where lookup values are a list of values with comma delimiter

I am trying to sum values based that equal a lookup value. However, that value is actually a list of values delimited by a comma. Below is an example of what I mean.
Suppose I have raw data in the form of sheet1 below:
Sheet1:
A
B
1
ID
VALUE
2
A
30
3
A
50
4
A
20
5
B
10
6
B
20
7
C
70
8
C
40
9
D
30
10
E
50
11
F
20
12
F
30
13
G
10
And I have a look table that groups all IDs by their respective teams, as per sheet2 below.
Sheet2:
A
B
1
TEAM
IDS
2
Red
A, B
3
Blue
C, D
4
Green
E, F, G
And I want to create a report where the user can select the team name, and the sum of the values in sheet1 will aggregate based on the selection, as per the following example. So the user would select "Green" in cell B1 and it would return the sum of values that correspond to E, F, and G in sheet1.
Report:
A
B
1
Select Team:
Green
2
Sum:
110
I have searched all over for a solution to this and was able to find something similar. I tried to repurpose the formula for my data but couldn't get it to work because I think that solution dealt with numbers rather than text.
Excel: Perform a SUMIF where the criteria is a comma-delimited list
Any suggestions would be greatly appreciated!
Edit: Just want to add that I realize I could first parse out the IDs in sheet2, however I'm looking for a formula that can bypass that as my real dataset is quite large and parsing out the IDs under each team would explode the number of rows.
A variation of #JvdV solution on the linked question:
=SUMPRODUCT(SUMIFS(Sheet1!B:B,Sheet1!A:A,FILTERXML("<t><s>"&SUBSTITUTE(VLOOKUP(Sheet2!F1,Sheet2!A:B,2,FALSE),",","</s><s>")&"</s></t>","//s")))
Note, this only works with Excel 2013 or later and only on PC. FILTERXML is not available on Mac or prior to 2013.
If Mac or prior to 2013:
=SUMPRODUCT(SUMIFS(Sheet1!B:B,Sheet1!A:A,TRIM(MID(SUBSTITUTE(VLOOKUP(F1,Sheet2!A:B,2,FALSE),",",REPT(" ",999)),(ROW($ZY1:INDEX($ZY:$ZY,LEN(VLOOKUP(F1,Sheet2!A:B,2,FALSE))-LEN(SUBSTITUTE(VLOOKUP(F1,Sheet2!A:B,2,FALSE),",",""))+1))-1)*999+1,999))))

Assign one value at the time from a column i Excel if the value is the same

I got some help with a problem finding column values in Excel: Find column value Excel
The table looks like this:
A 17 8,5 5,666666667 4,25 3,4 2,833333333 2,428571429
B 5 2,5 1,666666667 1,25 1 0,833333333 0,714285714
C 5 2,5 1,666666667 1,25 1 0,833333333 0,714285714
G 4 2 1,333333333 1 0,8 0,666666667 0,571428571
The code that I got help with basically selects A, B, C and G based of the order of the largest numeric value. The largest value is 17, that is one point for A, then comes 8,5 which gives another point for A. That works fine.
However, then comes 5. I now get B two times instead of first B and the C (the order does not matter, but I do not want to get two points for B when B and C have the same value). How can this be fixed?
(The real problem that this example illustrates is the number of seats on local boards in Swedish multiplicitets, where the number of seats for the different parties is based on the number of seats in the city council.)
Edit: Formula: =INDEX($J$16:$J$25,AGGREGATE(14,6,ROW($K$16:$W$25)/(K28=$K$16:$W$25),1)-ROW($J$16)+1)
Edit2: Wanted result:
Mandate Party
1 A
2 A
3 A
4 B
5 C
To do this by formulas, I think a simple way is to
unpivot the original data using formulas
Apply a unique rank formula to that data
Then use VLOOKUP to return ranks 1-n
The following formulas and defined names will be useful
origTbl =Sheet2!$A$1:$H$4
unpivotTbl =Sheet2!$A$8:$C$35
A8 =RANK(C8,$C$8:$C$35,0)+COUNTIF($C$8:C8,C8)-1
B8 =INDEX(origTbl,INT((ROWS($1:1)-1)/7)+1,1)
C8 =INDEX(origTbl,INT((ROWS($1:1)-1)/7)+1,MOD(7+ROWS($1:1)-1,7)+2)
Fill down A8:C8 to row 35
In the formulas in B8 and C8, the 7 is the number of columns in origTbl minus 1 (eg: COLUMNS(origTbl)-1)
Any changes you make in origTbl will be reflected in the final table
For appearances, you can certainly hide the UnPivot table someplace.
Note: in my locale, decimal separator is the dot

Match Data from Two Excel Files that Share Similar Attributes

I have two different Excel spreadsheets. They have almost the same data, but it has been updated so some entries are not there anymore or some items have been added.
I feel that this shouldn't be too difficult, but I cannot figure it out. I have attached a screenshot to help explain it.
I have some items that are labeled "I" or "O" for inside or outside in the "E" columns. I need these in my new spreadsheet, and there are 300 or so of them.
The values that are the same and need to match are KVA, LOW_VOLTAGE,COXX, and HIGH_VOLTAGE (rows A, B, C, and D).
I would like to somehow have the formula look at these values from the original sheet, and if they are the same, it will put an "I" or "O" in the field "E" in my new sheet.
Thank you very much for helping me!
(I can't post an image yet, so I tried to break it down here. Notice that only one row matches, so I would like that to update with "I".)
Original Sheet
A B C D E
1.5 120 99 7000 I
5 300 143 10000 O
NEW SHEET
A B C D E
1 100 87 500
1.5 120 99 7000
20 450 10 200
*rows A, B, C, and D is confusing but perhaps concatenate values from the original sheet, in a helper column (say F) along the lines:
=A2&"|"&B2&"|"&C2&"|"&D2
copied down to suit and then in the new sheet something like:
=IF(ISERROR(VLOOKUP(A2&"|"&B2&"|"&C2&"|"&D2,Original!F:F,1,0)),"O","I")
copied down to suit.

Comparing 2 columns to produce an answer for column 3

I need a formula, that looks for a number an entry in column A, then checks for yes or no (Y/N) in column B, and provides me with the answer from column C, the reason I require it is because whoever uses this sheet won't actually have access to the information (security reasons) so it will be in a hidden tab and this formula will be on a seperate sheet.
A B C
row 1 13 Y 10
row 2 15 Y 11
row 3 15 N 12
row 4 17 Y 13
So in the above example, i want to be able to look for 15 and N, and it provide me with 12
Im sure it's fairly straight forward for you guys but I'm getting nowhere, please let me know if you need any further information and I hope my formatting is okay!
This is just a case of a two column match. There are a few ways of performing this lookup; I prefer this standard formula method.
        
The formula in G2 is,
=IFERROR(INDEX(C$2:C$999, SMALL(INDEX(ROW($1:$998)+((A$2:A$999<>E$2)+(B$2:B$999<>F$2))*1E+99, , ), ROW(1:1))), "")
I've made that a bit more complicated than you requested. If you fill the formula down, you will receive successive matches (as per the modified data in the image above).

Count data if row is true excel

I have this Data:
var number
a 1
a 4
a 30
b 4
b 50
b 6
b 4
ab 1
I need to find the sum of each time a (var occurs X the number next column right) in excel.
In the case above the answer would be:
a = 36
b = 65
How can I write a formula for this in excel? Can I do this in excel?
Since you are counting the last one as well, I would use this formula:
=SUMIF(A:A,"*"&D2&"*",B:B)
Here, there is the value a in cell B2 and I can drag the formula down for B instead of typing a whole new formula. Handy if you have many like those to look for.
I assume that you have the table you published above in cells A1:B8. In order to do the calculating you would like to do you need to use the array-functionality in Excel. The following syntax in a cell will do:
=SUM(IF("a"=A1:A8,B1:B8))
However, instead of ENTER you need to press COMMAND+SHIFT+ENTER (I am on a Mac so it might be that Windows has a slightly different key combo. The result is that the formula now reads like:
{=SUM(IF("a"=A1:A8,B1:B8))}
This will give you 35 and not 36, but in a similar manner you could sum all the columns with 'ab' and then add that up to the sum of the 'a' columns.
Good luck!

Resources