Calculating the difference between two columns based on a match on two columns and displaying that result - excel

I have a question regarding find matching values between two columns, returning the values adjcent to those column and then working ou the difference. The problem is, I can't use a Vlookup because the data that I am trying to find a match has duplicates. Here is the structure of the table:
ITEM | Stock_1 | sellable_1 | SKU | Stock_2 | sellable_2
1 0 2 1 0 1
2 0 9 2 0 2
1 0 1 2 0 1
Now, I basically want to say where Item and SKU match, return to me the matched values, along with the stock_1, sellable_1 stock_2, sellable_2.
So essentially, ill have this:
mathced | stock_1 | sellable_1 | sku | stock_2 | sellable_2
Is there a way of doing this on excel?
Please help

*To use a worksheet formula to compare the data in two columns, follow these steps:
Start Excel.
In a new worksheet, enter the following data (leave column B empty):
A1: 1 B1: C1: 3
A2: 2 B2: C2: 5
A3: 3 B3: C3: 8
A4: 4 B4: C4: 2
A5: 5 B5: C5: 0
Type the following formula in cell B1:
=IF(ISERROR(MATCH(A1,$C$1:$C$5,0)),"",A1)
Select cells B1:B5.
In Microsoft Office Excel 2003 and in earlier versions of Excel, point to Fill on the Edit menu, and then click Down.
In Microsoft Office Excel 2007 and Excel 2010, click Fill in the Editing group, and then click Down.*
https://support.microsoft.com/en-us/help/213367/how-to-compare-data-in-two-columns-to-find-duplicates-in-excel

Related

How to SELECT N values ABOVE and BELOW from specific value

If I have a table:
Column A
Column B
Column C
1
Jane
10
2
Stewe
9
3
John
8
4
Mike
7
5
Luke
6
6
Andrew
5
7
Carl
4
8
Sasha
3
9
Ariel
2
10
Carol
1
I would like to SELECT 3 rows above and below WHERE Column B = someValue .
IF query SELECT * WHERE Column B = "Andrew" result should look like:
Column A
Column B
Column C
3
John
8
4
Mike
7
5
Luke
6
6
Andrew
5
7
Carl
4
8
Sasha
3
9
Ariel
2
I know how to select one row, but cant understand how to select such range.
Thanks for ideas!
You can limit and offset inside your QUERY():
=QUERY(A1:C,"limit "&2+MIN(5,MATCH(D1,B:B,0))&" offset "&MAX(0,MATCH(D1,B:B,0)-5))
Well, this was fun...
If 3 above or below are not available then blank... rolling data around is a different proposition.
Below the image is the list of formulae used.
So, per cell not including the data validation that is based on cells B2:B11
A14 and dragged down:
=IFERROR(INDEX($A$2:$A$11,MATCH(B14,$B$2:$B$11,0)),"")
C14 and dragged down:
=IFERROR(INDEX($C$2:$C$11,MATCH(B14,$B$2:$B$11,0)),"")
Cells B14 through B20:
=IFERROR(IF(MATCH(B$17,$B$2:$B$11,0)=3,NA(),INDEX($B$2:$B$11,MATCH(B$17,$B$2:$B$11,0)-3)),"")
=IFERROR(IF(MATCH(B$17,$B$2:$B$11,0)=2,NA(),INDEX($B$2:$B$11,MATCH(B$17,$B$2:$B$11,0)-2)),"")
=IFERROR(IF(MATCH(B$17,$B$2:$B$11,0)=1,NA(),INDEX($B$2:$B$11,MATCH(B$17,$B$2:$B$11,0)-1)),"")
=E2
=IFERROR(INDEX($B$2:$B$11,MATCH(B$17,$B$2:$B$11,0)+1),"")
=IFERROR(INDEX($B$2:$B$11,MATCH(B$17,$B$2:$B$11,0)+2),"")
=IFERROR(INDEX($B$2:$B$11,MATCH(B$17,$B$2:$B$11,0)+3),"")
In Excel 365, you could try:
=INDEX(A:C,MAX(2,MATCH(D2,B:B,0)-3),0):INDEX(A:C,MIN(COUNTA(B:B),MATCH(D2,B:B,0)+3),0)
In Google sheets, on the other hand, the formula would be:
=INDEX(A:C,MAX(2,MATCH(D2,B:B,0)-3),0):INDEX(A:C,MIN(COUNTA(B:B),MATCH(D2,B:B,0)+3),0)
(spot the difference).
Excel
Google Sheets
This should produce what you want in all cases:
=IFERROR(FILTER(A2:C,B2:B<>"",ROW(A2:A)>=VLOOKUP("Andrew",{B2:B,ROW(B2:B)},2,FALSE)-3,ROW(A2:A)<=VLOOKUP("Andrew",{B2:B,ROW(B2:B)},2,FALSE)+3))
Of course, you can replace the two instances of "Andrew" with a cell reference (one where you type a changeable name).
This just looks up the row in a curly-bracket array formed from the names and row numbers and uses FILTER to keep results to rows between +/-3 rows of where the target name is found. If you choose the first name (or any other name), you won't get an error; because even if the target name were on Row 1 and the formula goes looking for anything "greater than or equal to 1 minus 3, all rows will be greater than a negative number. Same on the high end. You just won't get a full seven names if there aren't at least three other rows prior to or after the target row.
this not the best solution but it will work , you can use a helper column 'D' that contains the following formula =if(countif(INDIRECT("B"&ROW()+3&":"&"B"&ROW()-3),"Andrew")>0,TRUE,FASLE)
and u can query from here like this SELECT * WHERE Column D = TRUE

Find first n summed values in Excel with criteria

I have the following table:
Sheet 'raw':
Account | Value
A 2
A 3
B 5
C 2
A 1
B 4
D 8
F 18
D 4
What I would like to capture the top n accounts by sum of values using only Excel formulas:
Sheet2:
Top | Account | Sum
1 F 18
2 D 12
3 B 9
4 A 6
4 C 2
I tried this approach (considering A to C columns in Excel):
- for the value:
{=LARGE(ROUND(raw!B$2:B$65000,2)+ROW(raw!B$2:B$65000)/10000),A2)}
for the account name:
{=INDEX(raw!$A$2:$A$65000,MATCH(A2,(ROUND(raw!B$2:B$65000,2)+ROW(raw!B$2:B$65000)/10000),0))}
I use array formulas for that, but it will provide me the top individual values not the sum per account
Could someone help me on this topic?
Thank you in advance!
With your dataset following seems to work:
In cell C2, CTRL+SHIFT+ENTER and not just ENTER following formula:
=LARGE((ROW(Sheet1!$A$2:$A$10)=MATCH(Sheet1!$A$2:$A$10,Sheet1!$A$1:$A$10,0))*SUMIF(Sheet1!$A$2:$A$10,Sheet1!$A$2:$A$10,Sheet1!$B$2:$B$10),ROWS($C$2:$C2))
In cell B2, CTRL+SHIFT+ENTER and not just ENTER following formula:
=INDEX(Sheet1!$A$2:$A$10,MATCH(Sheet2!C2,(ROW(Sheet1!$A$2:$A$10)=MATCH(Sheet1!$A$2:$A$10,Sheet1!$A$1:$A$10,0))*SUMIF(Sheet1!$A$2:$A$10,Sheet1!$A$2:$A$10,Sheet1!$B$2:$B$10),0))
Edit: There's typo in the formula Sheet2!D2 should be Sheet2!C2.Above formula is corrected.
CAUTION: Formula may give incorrect results if totals tie.

Excel Function Help - Compare 2 Cells in Worksheet to 2 Cells in another worksheet, if they match, return value from a different column

I'm wondering if someone would be able to offer some advice on the best way to do this please:
Data in Worksheet # 1
Col A | Col B | Col C
Part-1 | 8 | 2
Part-2 | 7 | 7
Part-7 | 9 | 4
Part-8 | 2 | 6
Data in Worksheet # 2
Col A | Col B | Col C
Part-1 | 8 | *Return value* (If Part-1 is found and 8 matches, return 2)
Part-2 | 7 | *Return value*
Part-3 | 8 | *Return value*
In Worksheet#2 in Cell C2 - I would like to check if the Part-1 in A1 is found in Col A in Worksheet#1. If it is, then I would also like to make sure the Number is B2 in Worksheet#2 matches the Qty in Col B next to the same part#, if both the Part# and Qty match, then i would like to copy across the value from the corresponding cell in Col C in Worksheet#1, to Col C in Worksheet#2. If it does not match, I would like it to return a 0.
Here is the a variation on Reinier's second approach in a form that will work in any version of Excel. You can use references to the specific data ranges, as I have done here, or to entire columns.
=SUM((A2=Sheet1!$A$2:$A$5)*(Sheet2!B2=Sheet1!$B$2:$B$5)*Sheet1!$C$2:$C$5)
This is an array formula, so it needs to be entered with the Control-Shift-Enter combination. It performs the same operation as the SUMPRODUCT. (There are several other ways to do this, such as using MATCH with INDEX or OFFSET.)
Essentially, what you are doing is a lookup based on values in two columns. Looking at it from that angle, you can use a the SUMPRODUCT function, which is supported in any version of Excel. Enter the following in Sheet2, cell C2:
=SUMPRODUCT((Sheet1!$A:$A=$A2)*(Sheet1!$B:$B=$B2)*Sheet1!$C:$C)
Select and drag down the right-bottom corner of C2 to complete column C.
This only works by virtue of the fact that the values in Sheet1, column C, are numbers. It breaks if value pairs in column A and B of Sheet1 occur multiple times, but you did not address that situation in your question in the first place.
For versions 2007 and up, you can use the more convenient function SUMIFS with basically the same approach:
=SUMIFS(Sheet1!$C:$C,Sheet1!$A:$A,$A1,Sheet1!$B:$B,$B1)
Alternatively, you can use a combination of IF and VLOOKUP functions. A formula that will work for Excel 2007 or newer is the following:
=IFERROR(IF(VLOOKUP($A1,Sheet1!$A:$C,2,FALSE)=$B1,VLOOKUP($A1,Sheet1!$A:$C,3,FALSE),0),0)
Older versions of Excel do not support IFERROR, but you can still use a similar approach as explained here.
I have uploaded an example workbook here, which includes an alternative method in column D of Sheet2 as well.

Microsoft Excel 2010: Help making a Formula to up Values by a repeating pattern

I have a Spreadsheet, and inside this sheet contains a column with numbers, I want to make a formula that will go down that Column and do basically this.. Values: 1 will be 9.50. 2 will be 9.75. 3 will be 10.00. Ect going up to Value of 100? Is that possible for a Formula? I keep playing with it but can't really seem to get it down. Any help would be appreciated.
Column A: 1
1
1
1
1
2
2
2
2
2
2
2
2
2
3
3
3
3
There is not a set amount to how many values are in there.
this should do it supposing that column A has these values 1, 2 ...etc that your computing will be based on
=MIN(9.25+A1*0.25;100)*COUNT(A1)
In A2, enter the formula
=A1 + (9.5-A1)
then in the cell just below it (A3), enter
=A2+0.25
Assuming A1 is the top left. Copy the formula in A3, select the next 399 cells and paste. Then select A2 - A364 and copy. Then select B2 -xx364 and paste. xx is the last column with data. If you want, set the height of your first column to 0 to hide it.
=(A1-1)*0.25+9.5 where A1 contains any number you want

Please help..Anyone know how can I make a chart to sum all the data of each week only if values are greater than 0?

Basically I have a table like this:
Week | Value
1 | 2
2 | 3
2 | -1
2 | 1
2 | 1
3 | 4
3 | 2
6 | 4
7 | 1
I need a chart to show the sum of the values for each week only if the value is greater than 0.
so
week 1 --> 2
week 2 --> 5
week 3 --> 6
week 6 --> 4
week 7 --> 1
Anyone have any idea how to do this?
If you have Excel 2007/2010, you can use the newer function SUMIFS as below:
=SUMIFS(Week_Values,Week_Numbers,This_Week2,Week_Values,">0")
This is two criteria, so you either need an intermediate column, or an array formula.
Option 1 - Extra Column:
Add a 3rd column, which has =IF(This_Value>0,This_Value,0) (where This_Value is the cell for that row with the value in it) and then do your SUMIF on the week number to sum up the new column; OR
Option 2 - Array Formula:
For each week number as This_Week in its own cell: =SUM(IF((Week_Numbers=This_Week)*(Week_Values>0),Week_Values,0)) which you must finish up with Ctrl-Shift-Enter instead of just Enter. More on Array Formulas at cpearson.com and Microsoft.
When you have more than one condition you could use SUMPRODUCT (simpler than Array formulas).
In this case suppose you have the data you propose on the cells A1:B10 (with column names Weeks and Values in A1:B1).
then put in D2 the number of the week for which you want the sum (say: 2)
Then:
=SUMPRODUCT(($A$2:$A$10=$D2)*($B$2:$B$10>0)*$B$2:$B$10)
would do.
PS: be aware that you must esclude the column names from the selection of SUMPRODUCT (i.e. do not use $A$1:$A$10 in the above formula)

Resources