Excel: Arrange Rows to Match Another Row - excel

I have a database with a column A with some values, and then 2 additional columns: Column B contains a bunch values that will match the ones in column A, but are not in order. I also have a Column with information that pertains to that specific row, amnd would like it to stay in 'sync' with column B. For example:
| A | B | C |
1 3 A
2 1 F
3 2 D
4 5 R
5 4 P
I'd like a way to sort it so my result would be:
| A | B | C |
1 1 F
2 2 D
3 3 A
4 4 P
5 5 R
Is there a way to do this?
If possible, if there is no match, delete the row?

In Excel 2007/2010,
simply select the cell with the "B" in it and go to the Data tab along the top and click on the A to Z button which is near the middle of the data tab. As long as B & C are adjacent columns, they will sort according to your needs. Please Note, Column A must not be adjacent to the other 2, otherwise you would run through the same procedure above but you would highlight columns B and C and perform the same sort button steps. If it gives you a Sort Warning, click the "Continue with the Current Selection" radio button and OK.

Related

Excel Formula comparing two columns

Below is a sample of the data I have. I want to match the data in Column A and B. If column B is not matching column A, I want to add a row and copy the data from Column A to B. For example, "4" is missing in column B, so I want to add a space and add "4" to column B so it will match column A. I have a large set of data, so I am trying to find a different way instead of checking for duplicate values in the two columns and manually adding one row at a time. Thanks!
A B C D
3 3 Y B
4 5 G B
5 6 B G
6 8 P G
7 9 Y P
8 11 G Y
9 12 B Y
10
11
12
11
12
I would move col B,C,D to a separate columns, say E,F,G, then using index matches against col A and col B identify which records are missing.
For col C: =IFERROR(INDEX(F:F,Match(A1,E:E,0)),"N/A")
For col D: =IFERROR(INDEX(G:G,Match(A1,E:E,0)),"N/A")
Following this you can filter for C="N/A" to identify cases where a B value is missing for an A value, and manually edit. Since you want A & B to be matching here col B is unnecessary, final result w/ removing col B and C->B, D->C:
A B C
3 Y B
4 N/A N/A
5 G B
6 B G
7 N/A N/A
Hope this helps!

Sum values if multiple conditions met in different sheet

I have one sheet that creates a mapping of names to values (Map_Sheet). In another sheet there are values for each name in the mapping table (Data_Sheet). What I am trying to do is add values based on certain conditions in the mapping table. For example: I want to add all counts of dog by bread and color. So in the mapping table I would look for all dogs that are brown and of a certain bread and get their names and manually add them together. I want to have a formula that does the addition based upon multiple conditions from Map_Sheet.
Here is an example of the data:
Map_Sheet-
name|bread|color|age
a x b 2
b y w 3
c x b 2
d z f 4
Data_Sheet -
id|a|b|c|d
0 3 4 2 1
1 1 2 4 2
2 3 5 7 2
3 1 2 6 9
4 1 3 5 7
And for each ID in the data sheet I want a count of bread X with color B. So I would add for ID0 values for A and C, (3+2) - so ID0 = 5, etc for each id.
I cannot use VBA so I was looking into using INDEX and MATCH but I cannot wrap my head around it. Any ideas? Thanks!
If the row headers in the first sheet match the column headers in the second sheet, you can put this formula in (say) G2 of the second sheet.
=SUM(TRANSPOSE(Map!$C$2:$C$5="b")*C2:F2)
If the column headers in the second sheet were in a different order, you would have to use something like:-
=SUM(C2:F2*NOT(ISERROR(MATCH($C$1:$F$1,IF(Map!$C$2:$C$5="b",Map!$A$2:$A$5),0))))
Both of these are array formulae. You can add extra conditions to select breed as well as colour using the same basic pattern:-
=SUM(TRANSPOSE((Map!$C$2:$C$5="b")*(Map!$B$2:$B$5="x"))*C2:F2)
or
=SUM(C2:F2*NOT(ISERROR(MATCH($C$1:$F$1,IF((Map!$C$2:$C$5="b")*(Map!$B$2:$B$5="x"),Map!$A$2:$A$5),0))))

How to get cells value from previous visible row in excel formulas

Is it possible to write a formulas in Excel,to calculate value based on the previous visible row?
By applying a Filter on the columns, the previous visible row changes but the usual formals does not consider visibility of the previous row, so the result does not change by applying filters. For example:
Let's original values of the spreadsheet cells be:
A | B | C | D
1: 5 3 1
2: 9 1 1
3: 2 3 0
4: 7 8 1 =A3-B4 equals 2-8=-6
Now assume that we make a filter on C column to hide the third row so we have
A | B | C | D
1: 5 3 1
2: 9 1 1
4: 7 8 1 =A3-B4 is still equals -6 but I want to get: 9-8=1
Is it possible to get such a formulas? Thank you very much.
Try this formula
=LOOKUP(2,1/SUBTOTAL(3,OFFSET(A$1,ROW(A$1:A3)-ROW(A$1),0)),A$1:A3)-B4
The SUBTOTAL/OFFSET part returns a 1 or zero for each value in column A depending on whether it's visible or not, LOOKUP finds the last 1 (equivalent to the last visible value) and gives that value.

Group by Sum in Excel

Let's assume that I have the following table in Excel
A B
Item quantity_sold
A 3
A 4
A 1
B 5
B 2
D 12
C 3
C 7
C 8
and I need to sum up quantity_sold grouped by Item and print the results on the adjacent column only once per group, similar to the following
A B C
Item quantity_sold SUM_by_item_type
A 3 8
A 4
A 1
B 5 7
B 2
D 12 12
C 3 18
C 7
C 8
Is there any way I can achieve this without using Pivot Tables?
Try this formula in C2 copied down
=IF(A2=A1,"",SUMIF(A:A,A2,B:B))
That will give you a sum on the first row of each group - other rows are left blank
I'd create a smaller table alongside (or on a different sheet) and use
=SUMIF(A:A,"A",B:B)
where...
=SUMIF(different-item-range,"what you're looking for",things-to-add-together)
=SUMIF is all explained here: http://office.microsoft.com/en-gb/excel-help/sumif-function-HP010062465.aspx
Subtotal feature:
Click the Data tab in Excel's ribbon toolbar
Click the Sort button and sort by your category column
Click the Subtotal button and fill in the dialog as appropriate,
then click OK
Video example: https://www.youtube.com/watch?v=OBj30n_x5aQ

How to compare two columns value in excel?

I have over 100k rows of data like below:
ALLA,ALLA,"Company1, Inc.","Company1, Inc.",PSA,PSA,1,1,FALSE,FALSE
BCCO,BCCO,"Company2, Inc.","Company2, Inc.",PSB,PSB,1,1,FALSE,FALSE
CTTP,CTTP,"Company3, Inc.","Company3, Inc.",PSC,PSC,1,1,FALSE,FALSE
CMMZ,CMMZ,"Company4, Inc.","Company4, Inc.",PSD,PSD,1,1,FALSE,FALSE
I want to know how to figure if data in column 1 is the same as column 2, column 3 as column 4 and so on. How could I do that in excel?
Following Cory's formula, I found that I can compare whole columns using:
=if(A:A=B:B, "yay", "aww")
Problem is I have a header in the file:
c - symbol, symbol, c - companyname, companyname, c - tradingvenue, tradingvenue, c - tierrank, tierrank, c - iscaveatemptor, iscaveatemptor
Shouldn't this cause A:A=B:B to be false?
Given this:
| A | B |
---+-----+-----+
1 | X | X |
---+-----+-----+
2 | Y | Y |
---+-----+-----+
3 | Z | Z |
The formula =SUMPRODUCT(--(A1:A3=B1:B3)) will tell you how many times the A value matches the B value.
You should get 3 as a result here. If, for example, you change B3 to Q then it will give you 2.
To do this on two columns without specifying the end of the range, try:
=SUMPRODUCT(--(A:A=B:B),--(LEN(A:A)>0))
I've been using Excel since 1991, and unless you want to write a VB macro, I think the best way is to do the simple IF statement suggested in the comments. If you need to test several columns at once, which is what your question suggests, then I'd do
=IF(AND(A1=B1,C1=D1,E1=F1,G1=H1),0,1)
Fill that formula down the column and then you'll be able toinstantly count the number of rows that don't matchwith a data-filter, select all the rows which have a '1', so you'll be able to examine the rows that don't match

Resources