Formula to get crossed values - excel
I am trying to get values from other column, based on some logic, crossed logic, but I didn't get any result with the only thing I know: IF or VLOOKUP.
The table is in this way:
So basically there are groups divided by blank row, and in column D I want to add the value from column B, but according with other letter that the one from the row ( C is from Credit, D is from Debtor). So in first D5 I have C on the same row in A5, so I need to take value from D, which is 2, according to B6.
So sorry if this question is too easy or stupid, but I don't know much about excel formulas, other that the basic one.
I'd say the fastest way with formula takes two columns. The first one (let's say column C) will use this formula to define the blocks:
=IF(A5="",C4+1,IFERROR(C4+0,0))
It's meant for cell C5.
The second column will give back the actual result:
=SUMIFS(B:B,A:A,IF(A5="C","D",IF(A5="D","C","")),C:C,C5)
It's meant for cell D5.
Place them accordingly and drag them down to cover your list.
Then again: if you are looking just for the number and not for its sum (and therefore assuming all numbers are equal for each letter in each block), just use this one in cell D5 instead of the previous one:
=SUMIFS(B:B,A:A,IF(A5="C","D",IF(A5="D","C","")),C:C,C5)/COUNTIFS(A:A,IF(A5="C","D",IF(A5="D","C","")),C:C,C5)
Now if you were to use only IF and VLOOKUP functions, a possible solution could be this one:
A
B
C
D
E
F
G
Block index
0
What to search
What is
Value
Result
C
1
=IF(A5="",C4+1,C4)
=IF(A5="",C4+1,C4)&SE(A5="C","D",SE(A5="D","C",""))
=C5&A5
=B5
=IF(VLOOKUP(D5,E:F,2,FALSO)=0,"",VLOOKUP(D5,E:F,2,FALSO))
D
2
=IF(A6="",C5+1,C5)
=IF(A6="",C5+1,C5)&SE(A6="C","D",SE(A6="D","C",""))
=C6&A6
=B6
=IF(VLOOKUP(D6,E:F,2,FALSO)=0,"",VLOOKUP(D6,E:F,2,FALSO))
D
2
=IF(A7="",C6+1,C6)
=IF(A7="",C6+1,C6)&SE(A7="C","D",SE(A7="D","C",""))
=C7&A7
=B7
=IF(VLOOKUP(D7,E:F,2,FALSO)=0,"",VLOOKUP(D7,E:F,2,FALSO))
=IF(A8="",C7+1,C7)
=IF(A8="",C7+1,C7)&SE(A8="C","D",SE(A8="D","C",""))
=C8&A8
=B8
=IF(VLOOKUP(D8,E:F,2,FALSO)=0,"",VLOOKUP(D8,E:F,2,FALSO))
D
3
=IF(A9="",C8+1,C8)
=IF(A9="",C8+1,C8)&SE(A9="C","D",SE(A9="D","C",""))
=C9&A9
=B9
=IF(VLOOKUP(D9,E:F,2,FALSO)=0,"",VLOOKUP(D9,E:F,2,FALSO))
C
4
=IF(A10="",C9+1,C9)
=IF(A10="",C9+1,C9)&SE(A10="C","D",SE(A10="D","C",""))
=C10&A10
=B10
=IF(VLOOKUP(D10,E:F,2,FALSO)=0,"",VLOOKUP(D10,E:F,2,FALSO))
=IF(A11="",C10+1,C10)
=IF(A11="",C10+1,C10)&SE(A11="C","D",SE(A11="D","C",""))
=C11&A11
=B11
=IF(VLOOKUP(D11,E:F,2,FALSO)=0,"",VLOOKUP(D11,E:F,2,FALSO))
D
2
=IF(A12="",C11+1,C11)
=IF(A12="",C11+1,C11)&SE(A12="C","D",SE(A12="D","C",""))
=C12&A12
=B12
=IF(VLOOKUP(D12,E:F,2,FALSO)=0,"",VLOOKUP(D12,E:F,2,FALSO))
C
5
=IF(A13="",C12+1,C12)
=IF(A13="",C12+1,C12)&SE(A13="C","D",SE(A13="D","C",""))
=C13&A13
=B13
=IF(VLOOKUP(D13,E:F,2,FALSO)=0,"",VLOOKUP(D13,E:F,2,FALSO))
C
5
=IF(A14="",C13+1,C13)
=IF(A14="",C13+1,C13)&SE(A14="C","D",SE(A14="D","C",""))
=C14&A14
=B14
=IF(VLOOKUP(D14,E:F,2,FALSO)=0,"",VLOOKUP(D14,E:F,2,FALSO))
Related
How to find and replace from a List in Excel
Not using VBA but just simple excel, can anyone help me find a solution to this problem? Would greatly appreciate it! I have a list of Names in Sheet 1 like below - A 1 sp_abc_Rick 2 sp_abc_Jabba_the 3 sp_abc_Dany 4 sp_random_Rick 5 sp_random_Jabba_the 6 sp_random_Dany 7 sp_constant 8 sp_ripley_art_Dany 9 sp_ripley_art_Jabba_the 10 sp_wakeup I have a list of Mapping Table in Sheet 2 like below - A B 1 Rick Morty 2 Jabba_the Hutt 3 Dany Dragon I wish to have a result in Sheet 1, in column B, like below - A B 1 sp_abc_Rick sp_abc_Morty 2 sp_abc_Jabba_the sp_abc_Hutt 3 sp_abc_Dany sp_abc_Dragon 4 sp_random_Rick sp_random_Morty 5 sp_random_Jabba_the sp_random_Hutt 6 sp_random_Dany sp_random_Dragon 7 sp_constant sp_constant 8 sp_ripley_art_Dany sp_ripley_art_Dragon 9 sp_ripley_art_Jabba_the sp_ripley_art_Hutt 10 sp_wakeup sp_wakeup To give you a context of the number of rows. Sheet 1 will be bigger with more than 1000 rows. Sheet 2 (Mapping Table) is constant set of rows. Currently it is about 100 rows.
You can use a formula like shown below using LOOKUP(), SEARCH() with SUBSTITUTE() • Formula used in cell B1 =IFERROR(SUBSTITUTE(A1,LOOKUP(9^9,SEARCH($D$1:$D$3,A1),$D$1:$D$3), LOOKUP(9^9,SEARCH($D$1:$D$3,A1),$E$1:$E$3)),A1)
There you go. There may have other better solution. This is what I got. All in column B. =IFERROR(CONCAT(MID(A1,1,MATCH(1,(CODE(MID(A1,ROW($Z$1:$Z$255),1))<90)*(CODE(MID(A1,ROW($Z$1:$Z$255),1))>=65),FALSE)-1),INDIRECT(CONCAT("sheet2!b", MATCH(MID(A1, MATCH(1,(CODE(MID(A1,ROW($Z$1:$Z$255),1))<90)*(CODE(MID(A1,ROW($Z$1:$Z$255),1))>=65),FALSE), LEN(A1)), Sheet2!$A$1:Sheet2!$A$300, 0)))),A1) Break down is as follow; Let's start put things from Column C onward. Column C, to find the index of the first capital letter from the text. ref: http://dailydoseofexcel.com/archives/2007/02/21/find-position-of-first-capital-letter-in-a-string/ =MATCH(1,(CODE(MID(A1,ROW($Z$1:$Z$255),1))<90)*(CODE(MID(A1,ROW($Z$1:$Z$255),1))>=65),FALSE) Column D, cut the name part by using upper case letter index from column C, sp_abc_Jabba_the -> Jabba_the =MID(A1, C1, LEN(A1)) Column E, search row number from Sheet2 by matching Column D's name with Sheet 2's Column A, this will get matching row number from Sheet2. =MATCH(D1, Sheet2!$A$1:Sheet2!$A$300, 0) Column F, get Sheet2's Column B value by the row number from Column E. =INDIRECT(CONCAT("sheet2!b", E1)) Column G, Cut "sp_abc_" from "sp_abc_Rick" Concat "sp_abc_" with Column F's "Morty". If there is any error, use Column A value as default. . <- this dot is intentional. please ignore. =IFERROR(CONCAT(MID(A1,1,C1-1),F1),A1)
Try: Formula in B1: =BYROW(A1:A10,LAMBDA(a,LET(b,TEXTBEFORE(a&"|","_"&A12:A14&"|",-1),IFERROR(CONCAT(IF(b&"_"&A12:A14=a,b&"_"&B12:B14,"")),a)))) The concatenation with a "|" would assert we only replace values when at the exact end of the input. Just in case there would be a stray (for example) 'Rick' somewhere before the end.
Matching multiple value in excel using index and match
I used index and match to identify the values of the table and matched it. However I am facing trouble when I try to get b and c, a is matched correctly A. B C D. 1 a b c 2 fruit1 a 3 fruit0 4 fruit3 5 fruit5 a E F 1 fruit1 a 2 fruit0 c 3 fruit3 b 4 fruit5 a My formula is =Iferror(if(index(($f$1:$f$4), match($A2,$e$1:$e$4,0),match(b$2,$f$1:$f$4,0)) = b$2,index(($f$1:$f$4), match($A2,$e$1:$e$4,0),match(b$2,$f$1:$f$4,0)), ""),"")
If your data table is in E1:F4, and you are trying to look up the fruit names that appear in column A starting at A2, and place the correct letter next to them in column B, then there's no need for the IF and the sequences of MATCHes. All you need is this, pasted into cell B2 and copied down, is this: =IFERROR(INDEX($F$1:$F$4,(MATCH(A2,$E$1:$E$4,0))),"") An easier approach to this is just: =VLOOKUP(A2,$E$1:$F$4,2,FALSE) or to be safer: =IFERROR(VLOOKUP(A2,$E$1:$F$4,2,FALSE),"") And if you have access to O365 Excel and the newer XLOOKUP function, you can use the following examples. XLOOKUP incorporates the "not found" result so you don't have to do a separate IFERROR. Do do it on a cell-by-cell basis as you had before, put this in B2 and copy it down: =XLOOKUP(A2,$E$1:$E$4,$F$1:$F$4,"",0) If you want to go one step further, you can apply the XLOOKUP as an array or "spill" formula, you change the lookup_value to be the A1:A4 and it does the rest. Place this in B2 and it will fill B2 through B5: =XLOOKUP(A2:A5,$E$1:$E$4,$F$1:$F$4,"",0)
Return Multiple Unique Matches in Excel without Array Formula
Given an Excel table of shape Col. A Col B Col. C Col. D Col. E x 2 x 2 3 x 3 y 7 y 7 z -5 x 2 z -5 I want to return the first unique hit in Column B for argument "x" in Column D, the second unique hit in Column B for argument "x" in Column E and so forth. The formula I'm currently using in cell D1 for this is {=IFERROR(INDEX($B$1:$B$5,MATCH(0,COUNTIF($C1:C1,$B$1:$B$5)+($A$1:$A$5<>$C1),0)),"")} which is working. The problem I'm having is that since this is an array formula and since I'm analyzing a decent amount of data computation time for my sheet is too high. Is there an alternative for this functionality avoiding an array formula? Thanks!
Haven't got time to test this properly, but if you have Excel 365 you can use a single formula per row and it may be faster: =TRANSPOSE(UNIQUE(FILTER(B1:B10,A1:A10=C1))) in D1. EDIT To pull the formula down, you need static references as OP has pointed out. Probably should check for empty cells in column C as well, so formula becomes: =IF(C1="","",TRANSPOSE(UNIQUE(FILTER(B$1:B$10,A$1:A$10=C1))))
How to use SUMIFS and SUMPRODUCT function **with a multiplier column** for summing values if criteria range exists in a range?
This question refers to this Stack Overflow question. This is the original question: A B C a 3 d b 1 a c 8 e d 5 I want to use SUMIFS function, sum range is B1:B4, if the corresponding value in column A exists in column C, sum the values in column B, in this case the sum will be 3 + 5 = 8. The answer turned out to be: =SUMPRODUCT(SUMIF(A1:A4,C1:C3,B1:B4)) I would like to create the same result, but with a multiplier on one of the ranges. Here's my question: A B C D a 3 d 3 b 1 a 1 c 8 e 1 d 5 d 3 The only thing I would like to do differently is add a range D1:D3 that acts as a multiplier. In this case, the sum I want would be (3x3)+(5x3)= 24. One challenge is that the ranges are different sizes in the "Test Data" google sheet linked below. The "Test Data" sheet is an example of how I would like to total daily calories based on the number of servings of items that I eat as dictated by the "multiplier column." I would like the numbers in C2:C27 to be a multiplier and factored into the total in D36. For example, if I ate 2 servings of Beef, then 2 servings worth of Beef's calories would be displayed in the daily totals below the data. Currently, using the formula =SUMPRODUCT(SUMIF(Meal_Items!$A$2:$A$100,$D$2:$D$28,Meal_Items!$B$2:$B$100)), only 1 serving of beef is weighted. Test Data See linked Test Data set above
The original question could also be solved with this formula =SUMPRODUCT((COUNTIF(C1:C3,A1:A4)>0)+0,B1:B4) using that version it's a simple matter to add one or more multiplier columns =SUMPRODUCT((COUNTIF(C1:C3,A1:A4)>0)+0,B1:B4,D1:D4) Given discussion in comments this formula should do what you want in either Excel or google sheets =SUMPRODUCT(IFERROR(LOOKUP($D$2:$D$28,Meal_Items!$A$2:$A$100,Meal_Items!$B$2:$B$100),0),$C$2:$C$28)
If you have actually put A, B, C, etc into the header row (row 1) then this will not work until you either rename your header column labels appropriately or use data range references in place of the full column references I've provided. =B2*INDEX(B:B, MATCH(A2, A:A, 0))+B2*INDEX(B:B, MATCH(C2, A:A, 0))
In E1 enter: =IF(COUNTIF(C$1:C$4,A1)>0,1,0) and copy down. Then in another cell: =SUMPRODUCT((E1:E4)*(D1:D4)*(B1:B4)) Data is in column BWeights are in column DCriteria are in column E
Excel line up data
I'm a total Excel nub and can't find the answer I'm looking for. Must be easy peasy, but since I'm not into Excel I also don't know what to look for. Sorry if I'm having my question wrong. I have output in Excel like this: A 1 A 2 A 3 A 4 B 1 B 2 B 3 B 4 B 5 B 6 and I want it like this: A 1 2 3 4 B 1 2 3 4 5 6
this question is quite complex in a way. let me explain it more in detail: as you see above, we have two columns A and B, you have text strings in column A , these text strings could be repeated. As you see in the example, there are 4 As, 5 Bs, 3 Cs 1 D and 3 Es. In column B each one of these strings have different corresponding values. For example, text strings B in column A has five corresponding values in column B, namely 11, 12, 13, 14, 15, and 16. Now we want a list of UNIQUE values from column A, and lets say, we put this list in column C and then for each of these unique values in column C we want to list their corresponding cells in column B and put them HORIZONTALLY in front of each of these unique text strings in column C. For this you need two kinds of formulas: Formula 1 to calculate the list of the unique values in column A : this goes in C2:(leave C1 empty) =IFERROR(INDEX($A$1:$A$999;MATCH(0;FREQUENCY(IF(EXACT($A$1:$A$999;TRANSPOSE($C$1:C1));MATCH(ROW($A$1:$A$999);ROW($A$1:$A$999)); ""); MATCH(ROW($A$1:$A$999);ROW($A$1:$A$999))); 0)); "") this is an array formula, so press ctrl+shift+enter to calculate the formula, and drag and fill down as many as you want in column C. *Formula 2 to find and list horizontally the values from column B * =IFERROR(INDEX($B$1:$B$999;SMALL(IF($C2=$A$1:$A$999;ROW($A$1:$A$999)-ROW($A$1)+1);COLUMN(A$1)));"") this is an array formula, so press ctrl+shift+enter to calculate the formula, put this in D2 and drag and fill down until the last cell of column C. then select D2 to D6 and drag and fill horizontally. You should get all of the corresponding cells in front of each unique item. P.S. adjust the formulas to meet your regional settings by replacing ; with , I suppose. Finally here is the link to an example sheet downloadable from here .
This is very generic but hopefully will help. Highlight the cells that you want to transpose to. Type the equation..."=TRANSPOSE(B1:B4)" (edit as necessary). While the cells are still highlighted, press "ctrl+shift+enter". (brackets should appear around the equation) Finish editing the cells. Celebrate