Hi,
picture is sample data
Column A is BAG ID which contain duplicate
Column B is the item inside the Bag
Column C is status if item are received
at Column D want to show :
a) if Column C is "SIP" AND the bag id also show that any item inside same bag id is "sip" will show = "Bag & awb rcv"
b)if Column C is "not sip" AND the bag id also show that any item inside same bag id is "not sip" will show = "Bag not rcv"
c) if Column C is "NOT SIP" AND the bag id also show that any item inside same bag id is "sip" will show = "Bag rcv , awb SL"
THANKS!
Give a try on below formula-
=IF(C2="SIP","Bag & AWB rcv",IF(AND(C2="NOT SIP",COUNTA(UNIQUE(FILTER($C$2:$C$9,$A$2:$A$9=A2)))=1),"Bag not rcv","Bag rcv , awb SL"))
Related
Hoping someone can help on this. I am trying to identify where values are invalid.
I have a set of data that contains correct values for three fields where they are dependent of each other.Table 1 (Correct Dataset)
I have another set of data that contains values within these three fields and contains invalid values. How can I easily identify where the values are invalid? Table 2 (Invalid Dataset)
Table 1 (Correct Dataset):
Letter Color ProductName
A Red Product A
B Blue Product B
B Orange Product C
C Red Product D
Table 2 (Invalid Dataset)
Letter Color ProductName
A Red **Product D**
B **Red** Product B
B Orange Product C
**D** **Blue** Product D
I have pandas DataFrame like this:
feature name 1 feature name 2
0 A B
1 A B
2 A C
3 B C
4 B D
And I want to get a list of "features name 2" without names which occurring in "feature name 1"
So desired output would look like this:
list = [C,D]
since B is occurring in first column.
Use Series.isin in boolean indexing:
mask = df['feature name 2'].isin(df['feature name 1'])
L = df.loc[~mask, 'feature name 2'].unique().tolist()
Or numpy.setdiff1d:
L = np.setdiff1d(df['feature name 2'], df['feature name 1']).tolist()
print (L)
['C', 'D']
We have a scenario in excel (2010) where the list of values present in a dropdown change dynamically based on some column of that row. For eg. Consider the "Supervisor" dropdown in sheet1 below:
Emp Grade Supervisor
A 14
B 12
C 13
D 12
E 12
F 13
G 14
Now let's say there is a dropdown for the supervisor. For every employee, the supervisor can be a person of his grade or higher grades only. So, for eg. For grade 13 employee, can have a supervisor with grade 13 or grade 14 only, not grade 12.
How can I write a custom condition like this inside the list of values? I have tried with things like named range, offset etc. but none allows specifying custom conditions. Any help?
I found the following document to be helpful in creating dependent Data Validation dropdowns: DV0064 - Dependent Lists Clear Cells, which can be downloaded here (for free):
http://www.contextures.com/excelfiles.html#DataVal
You can tailor the example to your needs.
=OFFSET('validation pivot'!$A$1,0,1,COUNTIFS('validation pivot'!$A:$A,">="&B2),1)
The supervisor needs to be at least his pay grade (>=B2). In order to have it work you need to have the pivot inserted in validation pivot A1. How to create the pivot (hasty notes):
add grade and emp 'emp as subset
tabular view 'to have separate columns
repeat labels ' to be able to count them
remove autosums(both within and total) 'to not deal with evading it
hide column labels and filters 'same
descending order(grade) 'to get a simple match method
data: store none 'to refresh the descending order every time
See uploaded sample file.
This code (column A = EMP, B = Grade, C = Supervisor)
Sub test()
Dim actualgrade As Integer
Dim lastRowA As Integer
Dim numbers As String
lastRowA = Sheets("sheet1").Cells(Sheets("sheet1").Rows.Count, "A").End(xlUp).Row
For i = 2 To lastRowA '1 = headers
actualgrade = Cells(i, 2)
For j = 2 To lastRowA
If Cells(j, 2) >= actualgrade Then
numbers = numbers & " " & Cells(j, 1).Value
End If
Next j
Cells(i, 3).Value = numbers
numbers = ""
Next i
End Sub
Makes this result:
Emp Grade Supr
A 14 A G
B 12 A B C D R F G
C 13 A C F G
D 12 A B C D R F G
R 12 A B C D R F G
F 13 A C F G
G 14 A G
Feel free to change it like you need it
I am working on a spreadsheet - currently google docs but happy to see answers relating to other spreadsheet software.
I have a list of foods (column A - Food)
I have list1 of "scores" (column B - Score1)
I have list2 of "scores" (column C - Score2)
I would like to add two new columns, ideally ordering the food from column A according to the scores, both list1 and list2 - so one new column ordering the foods based on the score1 from column B, and the other new columns based on the score2 from column C.
An example usually helps, so here is what I have:
Food Score1 Score2
a 12 45
b 96 67
c 100 32
Now, this would be "Version 1", on the way to getting what I would like:
Food Score1 Score2 Order1 Order2
a 12 45 3 2
b 96 67 2 1
c 100 32 1 3
Or, even better, "Version 2" - use the food name in the new columns, in the right order according to scores:
Food Score1 Score2 FoodScore1 FoodScore2
a 12 45 c b
b 96 67 b a
c 100 32 a c
I suspect that getting "Version 1" is probably achievable (but don't know how to do it)
I suspect that getting "Version 2" is not possible without some sort of procedural programming?
Hope someone can help!
Cheers
Or, even better, "Version 2" - use the food name in the new columns, in the right order according to scores:
Let A2:A10 - is your food range, B2:B10 - score1 range, D2:D10 - destination range ( FoodScore1 in your example)
Works both in EXCEL and in GOOGLE-SPREADSHEETS:
=INDEX($A$2:$A$10,MATCH(LARGE($B$2:$B$10,1+ROW(A2)-ROW($A$2)),$B$2:$B$10,0))
enter this formula in D2 and drag it down
If formula will give you an error, try to change , to ; (depends on your local settings).
P.s. for score2 formula would be the same, just change ranges from score1 to score2 (i.e. $B$2:$B$10 to $C$2:$C$10)
I would start by adding a rank column, with number 1 for the highest score, number 2 for the second highest, etc.
In Microsoft Excel, assuming that the first column is A and that all the scores are unique, you could simply have a formula like
=COUNT.IF(B:B, ">=" & $B1)
in column D1, and similarly in column E for the second score.
Then if you fill column F with the ranks 1, 2, 3, ... you can simply do a VLOOKUP. Or, in this case, an equivalent solution with INDEX and MATCH - because you want to lookup the rank in column F and return the corresponding value from column A.
As you are working in a Google Spreadsheet, one would expect to see some Googliness in the solutions provided. Use this very simple, only usable in Google Spreadsheet, formula.
Formula
// FoodScore1
=QUERY(B2:D4, "SELECT B ORDER BY C DESC")
// FoodScore2
=QUERY(B2:D4, "SELECT B ORDER BY D DESC")
Screenshot
Explained
The data range of the QUERY function is simply B2:D4. Then a quasi SELECT statement is made to select only column B and ordered by column C or D, descendingly.
Reference
https://developers.google.com/chart/interactive/docs/querylanguage
I've got a problem which seems simple at first, but really isn't. I'm storing words in a table in such way that pair of strings "A B C D E" and "D E F" becomes:
id value
-- -----
1 A
1 B
1 C
1 D
1 E
2 D
2 E
2 F
And i pass to my ORACLE procedure string which looks like this: "A B C D G". And now I want to check percentage of similarity between strings in the database and string passed as a parameter.
I presume that I have to use one of split functions and use an array. Later check if every word in passed string occurs in the table and then count ids. But there`s a twist: I need precise percentage value.
So, result from example above should look like this:
id percentage
-- ----------
1 80 -- 4 out of 5 letters exists in query string (A B C D)
2 33 -- 1 out of 3 (D)
So, my questions are:
what is most effective way to split query string and then iterate on it (table?)
how to store partial results and then count them?
how to count final percentage value?
Every help would be greatly appreciated.
The following query would give you what you want without the need to bother with procedures.
select id
, sum(case when value in ('A', 'B', 'C', 'D', G') then 1 else 0 ) / count(*)
from my_table
group by id
Alternatively if you have to pass the string "A B C D G" and get a result back you could do:
select id
, sum(case when instr('A B C D G', value) <> 0 then 1 else 0 ) / count(*)
from my_table
group by id
These do involve full scanning the table or an index full scan if you use the suggested index below, so you might want to add the following where clause if you only want to find ids that have a percentage > 0.
select id
, sum(case when instr('A B C D G', value) <> 0 then 1 else 0 ) / count(*)
from my_table
where exists ( select 1
from my_table
where id = mt.id
and instr('A B C D G', value) <> 0 )
group by id
For all the queries your table should be indexed on my_table, id in that order.
Have you had a look at UTL_MATCH? It doesn't do exactly what you're trying to achieve, but you may find it useful if the definition of your percentage agreement isn't set in stone.