match multiple partial strings from string in excel - excel

So here I have 2 tables.
ring layer1 layer2 output
12 45 46 bingo
12 34 75
13 23 47
14 23 34 nice_work
14 12 15
14 45 23
14 67 89 wow
25 90 124
67 76 341
ring whole_string value as output
12 23_45_12_78_46 bingo
12 78_89_23_45_90 great
13 23_89_90 awesome
14 45_78_23_45_34 nice_work
14 88_86_85_12 cool
14 67_89_111 wow
what I need is: value as output from tbl2 if
1. tbl1 ring = tbl2 ring
2. tbl1 layer1 & layer2 values must be present in tbl2 whole_string
Can someone help me with excel formula?
Thank you...
I tried using a for loop. It takes a whole lot time.

You could use:
Formula in D2:
=IFERROR(INDEX($H$1:$H$7,AGGREGATE(14,3,($F$2:$F$7=A2)*(IF(ISNUMBER(SEARCH("_"&B2&"_","_"&$G$2:$G$7&"_")),1,""))*(IF(ISNUMBER(SEARCH("_"&C2&"_","_"&$G$2:$G$7&"_")),1,""))*ROW($F$2:$F$7),1)),"")
Entered as array formula through: Ctrl+Shift+Enter
Drag down...

Related

Python: How to find nth minimum value from a dataframe column?

Have got a dataframe like below:
Store Row_no
11 56
11 57
11 58
12 89
12 90
12 91
12 92
For each store need to get 3rd minimum value from Row_no. Expected output below.
Store Row_no
11 58
12 91
have tried df.Row_no.nsmallest(3) but it works different. Any help will be appreciated. Thank You!
Use DataFrame.sort_values with GroupBy.nth:
df = df.sort_values(['Store','Row_no']).groupby('Store', as_index=False).nth(2)
print (df)
Store Row_no
2 11 58
5 12 91

How to transpose column in several rows in excel

is there a way to transpose one column in excel into several rows. For example I have one column with 100 rows and I want to transpose it but also split it in several rows with 3 columns.
I have this:
21
34
2
56
23
12
34
18
22
...
I need this:
21 34 2
56 23 12
34 18 22
...
Thank you very much in advanced!
You could try this:
The formula used in C1 translates to:
=INDEX($A$1:$A$9,ROW(A1)*3-3+COLUMN(A1))
You can drag it sideways and down.

Counting combinations of values in table of values excel?

I have a table of values with each value in a different cell
e.g.
2 9 12 19 41 45 14 39
12 14 19 27 39 40 30 44
6 9 13 15 16 41 7 20
8 16 14 34 13 44 5 15
10 11 20 24 27 36 9 41
Is there a way to find which pairs of numbers are most common.
i.e.
13 & 15 appear 2 times
14 & 44 appear 2 times
24 & 27 appear 1 time
I was hoping for a formula as the table has over a hundred rows in it so would be time consuming to count manually.
The formula you would want would be the one for the row totals of a pair of numbers in A2 and B2:
=SUM(MMULT(--($E$2:$L$6=A2),TRANSPOSE(COLUMN(E:L))^0)*MMULT(--($E$2:$L$6=B2),TRANSPOSE(COLUMN(E:L))^0))
entered as an array formula using CtrlShiftEnter
There will be formulas for for listing distinct pairs up to a certain number out there - I used
=IF(ROW()=2,1,IF(B1<45,A1,A1+1))
for A2 and
=IF(B1<45,B1+1,2+COUNTIF(B$1:B1,45))
for B2.
If you scroll down this list you can see that 13,16 occurs twice as well as 13,15.
9,41 occurs three times.
Note - I am assuming the numbers are like lottery numbers and any one number can only occur once in a row. The formula could easily be modified to account for duplicates within a row.

how can I define sequence of used ID?

I have ProductID:
ProductID
12
85
14
14
14
17
65
65
I need to create a new column where i could count how many times i have the same ProductID. I mean:
ProductID Count
12 1
85 1
14 1
14 2
14 3
17 1
65 1
65 2
The formula I currently have is = IF((A3=A2),F2+1,1), but it doesn't work.
Use this formula if you want the count of each individual entry to be same. (i.e count for 14 will be 3 as it exists three times in the data set)
=COUNTIF($A$2:A9,A2)
Output is attached for your reference.
In B2 enter:
=COUNTIF($A$1:A2,A2)
and copy down

How to format a number to appear as percentage in Excel

So lets say I have a few numbers in a sheet
a b c d
1 33 53 23 11
2 42 4 83 64
3 75 3 48 38
4 44 0 22 45
5 2 34 76 6
6
7 Total 85
I would like to display those numbers so that the cell value still holds the original figure (A1 = 33)
but the cell displays both the number and a percentage from the total (B7) eg
a b c d
1 33 (39%) 53 (62%) 23 (27%) 11 (13%)
2 42 (49%) 4 (5%) 83 (98%) 64 (75%)
3 75 (88%) 3 (4%) 48 (56%) 38 (45%)
4 44 (52%) 0 (0%) 22 (26%) 45 (53%)
5 2 (2%) 34 (40%) 76 (89%) 6 (7%)
6
7 Total 85
I know how to format a cell as a percentage, but I can't figure out how to display both original values, the calculated percentage value (value/total*100), but not change the cell value so I could still sum the cells in the end (eg. A6 =SUM(A1:A5) = 196)
Does anyone have an idea? I was hoping there could be a way to duplicate and calculate the figure using text formatting, but I can't get anything to work.
I'm guessing this is a trivial answer and maybe not what you're looking for, but why not just add a column for each of the columns you have now?
a a' b b' c c' d d'
1 33 (39%) 53 (62%) 23 (27%) 11 (13%)
2 42 (49%) 4 (5%) 83 (98%) 64 (75%)
3 75 (88%) 3 (4%) 48 (56%) 38 (45%)
4 44 (52%) 0 (0%) 22 (26%) 45 (53%)
5 2 (2%) 34 (40%) 76 (89%) 6 (7%)
6
7 Total 85
#Ari’s answer seems to meet to meet the requirements in your question, not repeat information more than the example you gave for output requirement and be viable for up to around 8000 or so columns to start with (unless a very old version of Excel) and Jerry’s comment is also correct that what you want to achieve the way you want to achieve it is not possible.
However there are other approaches that might be acceptable substitutes. One is to copy your data and Paste Special with Operation Divide, either elsewhere or over the top of your data. If over the top this either shows the values or the percentages otherwise duplicates your data. Over the top would also require something like Operation Multiply to revert back to values, and reformatting each time if to appear as in your example.
Another is to use a PivotTable with some calculated fields and both are shown below:
I appreciate neither is exactly what you are asking for.

Resources