I need to create a string per row line that includes all elements that are present in that row but displaying the corresponding heading column text, while not representing (in the string) the element that is the label of the row. Explaining...
Consider the following table:
AAA
BBB
CCC
DDD
AAA
1
1
1
BBB
1
1
1
BBB
1
CCC
1
1
I expect the following result (for each table row):
Column A
BBB, DDD
AAA, CCC
DDD
Take notice that in the first row (which stand for element "AAA") that element does not appear in the string - same for "BBB" in the second line and "CCC" in the last line. For that same reason, the third line has an empty string as result.
In order to solve this, I'm creating a new table with each of the table heading element (that's not the row element) and then do a TEXTJOIN with ", " as separator. As follows:
AAA
BBB
CCC
DDD
AAA
BBB
DDD
=TEXTJOIN(", ";TRUE;B2:B5)
BBB
AAA
CCC
=TEXTJOIN(", ";TRUE;C2:C5)
BBB
=TEXTJOIN(", ";TRUE;D2:D5)
CCC
DDD
=TEXTJOIN(", ";TRUE;E2:E5)
Now, for sure it may be possible to do this without the need to create this extra table - or maybe to create such a table inline in the formula ?
You can use this formula:
=LET(
rH,B1:E1,
cH,A2:A5,
d,B2:E5,
BYROW(cH,LAMBDA(r,
TEXTJOIN(",",TRUE,
FILTER(rH,(rH<>r)*(CHOOSEROWS(d,ROW(r)-1)=1),"")
))))
It filters - per data-row - the header-row and returns only those values from the header row that don't match the rows first cell and have a 1 in the according column of the data row.
EDIT:
As per your comment - a one-liner that you have to drag down:
=LET(rH,$B$1:$E$1,cH,A2,d,B2:E2,
TEXTJOIN(",",TRUE,
FILTER(rH,(rH<>cH)*(d=1),"")
)
)
In this case you don't need the BYROW- part
Related
I am trying to do a sum product to compare a cell to a column in another sheet and bring the value in another column associated to the match.
Using :
=SUMPRODUCT(Item_mst!$H$1:$H$4,--(A1=Item_mst!$B$1:$B$4))
sheet 1
Item
A
1 aaa
2 bbb
3 ccc
Item_mst
Item Qty
B H
1 aaa 20
2 AAA 10
3 AAA 20
4 AAA 20
The above formula gives me aaa/AAA = 60 while the correct value answer I expect is 70. Its not picking up the item when the qty is different and the case doesnt match.
SUMIFS would be a better solution
But, to answer the actual Q, try
=SUMPRODUCT(Item_mst!$D$1:$D$4,--(LOWER(H1)=LOWER(Item_mst!$B$1:$B$4)))
I want to check if a value or text string in a given row in Table 1 is also present in a given column in Table 2. Of course I could do this column by column in Table 1 but with about 50 columns I don't really want to. My data looks something like this:
Table 1
1 aaa bbb ccc
2 ddd eee fff
3 ggg hhh iii
Table 2
1 bbb
2 xxx
3 ccc
You could use an array formula:
=SUM(IF(COUNTIF(Sheet2!$A$1:$A$3,$A1:$C1)>0,1,0))
Press CTRL-SHIFT-ENTER after entering it as opposed to ENTER
This will tell you how many exist in the list on sheet2 for each row in sheet 1
I have 2 sheets with different values. I need to find a value from one cell.sheet1 in sheet2 and copy value from nextcell_in_the_same_row.sheet1 to nextcell_in_the_same_row.sheet2.
It is very difficult to explain let look at the example bellow.
E.g.
Before
first sheet:
A B
1 aaa 123
2 bbb 456
3 ccc 789
4 ddd 122
second sheet:
A B
1 aaa
2 ada
3 cca
4 ccc
After
first sheet:
A B
1 aaa 123
2 bbb 456
3 ccc 789
4 ddd 122
second sheet:
A B
1 aaa *need to find value in the first sheet and copy value from B2 because aaa in A1*
2 ada *value does not exist in the first sheet so copy nothing*
3 cca *not need to copy because no value in the first sheet*
4 ccc *need to copy the value from B3*
Thank you so much!
Use a VLOOKUP along with an IFERROR.
=IFERROR(VLOOKUP(A1, Sheet1!A:B, 2, 0), "")
This will do what you described (well described, by the way!) in your question. Drag the formula down in Sheet2 till the bottom.
VLOOKUP takes the value of A1 in sheet 2 (no sheet reference because the value is in the same sheet as the formula) and looks it up in column A of Sheet1.
It returns the second value (hence why 2) of the table selected in the formula (column A is 1, column B is 2).
The 0 tells the VLOOKUP to look for exact matches. You don't need approximate match here.
And IFFERROR is there in case VLOOKUP doesn't find anything (like with ada) and instead of giving #N/A, returns an empty cell, "".
Trying to combine the data into one master sheet. I have something like below:
Sheet 1 Sheet 2 Sheet 3
Name Gain(Y/N) Name Gain(Y/N) Name Gain(Y/N)
AAA Y AAA Y AAA
BBB N BBB BBB N
CCC CCC Y CCC Y
DDD DDD DDD Y
EEE EEE EEE N
Ultimately would look something like (merging all the sheets into sheet1)
Sheet 1
Name Gain(Y/N)
AAA Y
BBB N
CCC Y
DDD Y
EEE N
The problem is that consolidate function won't work for Text string (Y/N)
I am thinking something like 'if vlookup' or match index? but for multiple reference?
and not overriding each other. Maybe there is simpler way...
Thanks for your help :D
=IF(OR(Sheet1!B2="Y",Sheet2!B2="Y",Sheet3!B2="Y"),"Y",IF(OR(Sheet1!B2="N",Sheet2!B2="N",Sheet3!B2="N"),"N",""))
in B2 of a new sheet and copied down may suit.
Edit Simplification of revised formula to reflect edit to question:
Filter Sheet1 for Gain (Y/N) (assumed to be ColumnB) for (Blanks) and in the cell with the smallest visible row number enter:
=IF(OR(VLOOKUP(A4,Sheet2!A:B,2,0)="Y",VLOOKUP(A4,Sheet3!A:B,2,0)="Y"),"Y",IF(OR(VLOOKUP(A4,Sheet2!A:B,2,0)="N",VLOOKUP(A4,Sheet3!A:B,2,0)="N"),"N",""))
Change 4s in A4s to smallest visible row number (adjust column references as necessary) and copy down as required.
If you don't mind creating an extra column on each sheet, you could turn "Y" and "N" into a number. Assuming your labels are in column A, you insert a new column B and put the following in B2:
=IF(A2="Y", 3, IF(A2="N", 2, 1))
Repeat for all sheets. Now you can do consolidation, using the "MAX" function. It will return 2 if the letter "Y" appeared anywhere, etc. Now you can get back to Y/N/blank by putting the following formula in a column next to the consolidated data:
=INDEX({" ","N","Y"}, B2)
This will return " " if B2 is 1, "N" if B2 is 2, etc. Finally you can copy the entire column, and "paste special - values" to get exactly what you wanted.
You might as well use Microsoft Query to fetch all the data into a pivot with a code similar to this:
SELECT Name, Gain, 'Sheet1' as [Sheet#]
FROM Sheet1
UNION
SELECT Name, Gain, 'Sheet2' as [Sheet#]
FROM Sheet2
UNION
SELECT Name, Gain, 'Sheet3' as [Sheet#]
FROM Sheet3
I need some help copying data from one excel worksheet to another. For example:
Sample Data
__A__B___C
1 aaa bbb ddd
2 bbb ccc eee
3 ccc fff rrr
4 ccc fff ttt
5 ddd eee ggg
6 aaa ddd eee
7 bbb fff hhh
8 eee eee eee
So for the above records if I do a 'CTRL + F' and search to find All 'eee' the results will show 6 instances in C2, B5, C6, A8, B8, C8
Now I want to copy the whole of rows 2,5,6 and 8 to another worksheet.
This worked for me... a simple solution:
Select/highlight the data you want to search
Press ctrl +h for Replace
Enter the string you want to find in "Find What".
Select "Replace with" Format, then Format > Fill and choose a background fill, doesn't matter what color. Then click [Replace All].
Then choose on the Excel menu > Data > Sort on "Cell Color",
Order (the color you chose from step 4 above) and then "On Top" or "On Bottom" - whatever you want, click [Ok].
Now all the data you wanted is all in one block of rows. Copy and paste to another worksheet as required.
To achieve what you need please do the following (assuming your data is located in columns A:C starting row 2, i.e. there are headers):
Type in D2 (additional column): =IF(OR(A2:C2="eee"),1,0), but press CTRL+SHIFT+ENTER instead of usual ENTER - this will define an ARRAY formula and will result in {} brackets around it (but do NOT type them manually!).
Autofill formula as required.
Add filter to the whole A:D range.
Apply filter to column D for value 1.
Copy entire filtered columns A:C and paste anywhere - only filtered rows will be copied.
Sample file: https://www.dropbox.com/s/qscwbf5kbnwi5pa/Filtering3Columns.xlsx
I think what you are looking for is called VLOOKUP just take the Excel-help, theres everything explained
The easiest way I found was this: Using the option "Sort & Filter" located in the right upper corner. Then you can filter any column by any criteria you like. By doing that only the filtered rows appear on the spread sheet (the rest are still there but just hidden). From there you can easily copy and paste the entire rows.