Compare two columns and get the values from another column? - excel

I have an excel table with multiple columns, I need to add value for every transaction_id, how can i compare column C with column J and enter values from K into D column?
Table looks like this:
C
D
J
K
transaction_id
amount
transaction_id
amount
1
5
1000
2
1
1000
5
118
200
118
117
500
I need to match the exact transaction_id and move from the right to left amount value if transaction id is the same, how can I do that?

Just use VLOOKUP:
Formula in D is:
=VLOOKUP(C2,$J$2:$K$5,2,FALSE)

Related

Aggregating records with two main IDs in [VBA macro]

I want to make a macro in Excel that summarizes data from rows that match a composite ID generated from 2 ID columns. In my excel sheet, each row has 2 main ID columns: ID_1 is the main key, and ID_2 is a secondary key from which I only care about the first 2 letters (Which I have gotten using LEFT). I want to group rows with the same ID_1 and first 2 letters of ID_2 and report the SUM of the value, count, and sum columns.
In the example picture below, I want to turn the data in columns A:J into the data in columns M:V
So, with this example -> We have 6 records 1015 (ID_1) with 3 different ID_2 (AB, AZ, AE). I want to sum them up to a one cell each (1015 AB ; 1015 AZ ;1015 AE) with values which each record had (there is 3 records: 1015 AB with VALUE of 2,3,4 so in result I want to get just one row 1015 AB 9(sum of value) 4(sum of count) 17 (sum of(value * count)). It's important to see that this 17 dosn't come from 9 * 4. It's =sum(I4:I6) (but it may be spread out like in 1200 FF example below! I am still trying to sort them both at one time, but I cant get past it..)
Add a helper column in D to combine the ID_1 and the first 2 characters of ID_2. =A4 & LEFT(C4,2). Copy that down then go to L4 and type in:
=+INDEX($D$4:$D$25,MATCH(0,COUNTIF(L$3:L3,$D$4:$D$25),0)
and hold down Ctrl + Shift + Enter to make it an array function. Copy down to get a list of unique combinations, and then split these values into the separate columns.
Finally to pull in the numbers, put this in Q4:
=SUMIFS(E$4:E$25,$A$4:$A$25,M4,$C$4:$C$25,O4 & "*")
and then copy down and across.

Grouping rows together in excel if they are scattered based on a field

Lets say we have an excel with customerid and amount . If i sort the excel on amount my customers will be scattered. So i want to achieve sort and then group same customers amount tohether maintaining that sort.
If i have below
Row 1 . X 200
Row 2. Y 245
Row 3. Z 45
Row 4. Y 456
Row 5. Z 23
Row 6. T 5678
I want output as :
T 5678
Y 456
Y 245
X 200
Z 45
Z 23
When you select a single column and perform a sort, it disregards values from other columns. So, before sorting your Excel sheet, you need to select the entire sheet:
After that, choose "sort" from the menu, and select sort by column A and then by column B:
Result:
Please see the sorted data on Column B (modified data for Z as 999).
Sorted on Column B
Now below is the result i want to achieve.That is , after sorted on Column B , the rows should re-arrange such that the customers data gets together. Result as below, we can see that 2nd last row z 999 had to be moved , putting below Z 23.
Final Result

In Excel how do subtract values from list table when I preform a transaction?

If I have two tables where I have list of things in 1 table and the other table serves as a transaction table. But every time I do a transaction the value of units in the transaction should be subtracted from the lists table. Can anyone please help?
Let's say table 1 looks like this:
A B C
1 Item Start Value Current Value
2 ---- ----------- -------------
3 1 20
4 2 100
5 3 95
and table 2 has transactions recorded as a list of Item numbers in column E and associated value movements in column F, then the formula in C3 should be:
=B3-SUMIF(E:E,A3,F:F)
This formula can then be copied down for the other entries in table 1

Vlookup doesn't work with column of string

I have 4 columns, containing 2 columns of names and 2 columns of values, as below. I need to update Column B with value in K, if the name1 = name2. Both name columns are formatted as text, and values columns are formatted as numeric.
(A) Name1 (B) Value1 (J) Name2 (K) Value2
A A 123
B B 456
C X 000
D Y 000
E Z 000
F C 789
I insterted the following vlookup in the first row of column B, but it returns the name in column A.
=VLOOKUP(A4,J2:J22890,K2:K22890)
I'm expecting to have the following result:
(A) Name1 (B) Value1 (J) Name2 (K) Value2
A 123 A 123
B 456 X 000
C 789 B 456
D Y 000
E Z 000
F C 789
Am I using vlookup a the wrong way? or is it due to the fact that I'm looking up strings??
I think it should be
=VLOOKUP(A4,J2:K22890,2,0)
1.First parameter is the value you are looking for,
2.second one is the range (it can be multiple columns, with the referenced data in the most-left column of the selection),
3.followed by the column's number where the records should be retrieved from,
4.and lastly a flag (1 or 0) if you would like to accept similar results (1) or exact matches only (0)
Since I can't edit the post because it's not enough characters and I can't comment because I don't have enough rep...
=VLOOKUP(A4,$J$2:$K$22890,2,0)
This is Alex's post with absolute references for the lookup table array.

How to only count unique record once and based on that count Yes or No

I have 3 columns
ORDER, ID and E Yes/NO
In Column C order
In Column D ID
In Column E Yes/No
For example for ID = 144. I need count to how many order it was given to 144.
so looking at sample table below 144 was given 1 order which was 821 and column is Yes for 144 and when Order = 821.
Another example ID=162.
was given 2 order , 861 and 992. so his total order count is 2 and # of Yes count is 1 because row 13 is No.
I am really stuck on this complex logic.
Any feedback would be appreciated.
Given the layout shown, try these in B17 and C17 respectively, then fill down:
=SUM(IF(FREQUENCY(IF(MMULT(-(D$2:D$13=A17),1),C$2:C$13),C$2:C$13),1))
=SUM(IF(FREQUENCY(IF(MMULT((D$2:D$13=A17)*(E$2:E$13="YES"),1),C$2:C$13),C$2:C$13),1))

Resources