Conditional Relate ID with email and name - filter

I'm trying to create a relation from some tables we could that the ID is the team they belong to, and the division is their role.(IN google sheets)(This table of information is in Sheet7)
Now I'm trying to create a conditional IF B2(Value) is lower than 0.8 give me the name and email from the person with the id and the division corresponding to that value. Here is my formula but it's not working =vlookup(A2,if(B2=>0.8;Sheet7!A1:D16;""),2,0) some help please! (This values tables is in Sheet8)

try in F2:
=INDEX(IF(B2:B5>=0.8, IFNA(VLOOKUP(A2:A,
FILTER({Sheet7!C:C, Sheet7!A:D}, Sheet7!D:D=B1), {2, 3}, 0)), "xxx"))
update:
=INDEX(IFNA(VLOOKUP(INDEX(SORT(QUERY(SPLIT(FLATTEN(
COLUMN(B1:E1)&"×"&B1:E1&A2:A&"×"&SUBSTITUTE(B2:E; "."; ",")*1); "×");
"where Col2 matches '.*\d+$' and Col3 < 0.8"));; 2);
{Sheet7!D:D&Sheet7!C:C\ Sheet7!A:D}; {2\ 3}; 0)))

Related

Google Sheets Formula that finds employee with most hours worked for a specific location and shift (INDEX/MODE with multiple Criteria)

In Google Sheets, I need to find out which employee works more than 50% of the hours for a given shift at a given location based on timecard data (Table in col G:J). In the attached google sheet I need a formula in Column C that returns the name of the matching employee useing Column A & B for criteria, then column D and E should auto calcuate.
https://docs.google.com/spreadsheets/d/1HE90e1hVvsEIiFbNdb3sQ042LHMZhxyCno72eZMA79k/edit?usp=sharing
I was previously using an ArrayFormula with INDEX/IF/MODE/MATCH (example in cell C15) but that could only return the employee with the most shifts and was not able to differentiate by criteria.
Thanks in Advance!
delete everything in C2:D7 and use this in C2:
=INDEX(IFNA(VLOOKUP(A2:A6&B2:B6, SORT(QUERY({H2:H&J2:J, G2:G, I2:I},
"select Col1,Col2,count(Col1),sum(Col3) group by Col1,Col2"), 3, 0), {2, 4}, 0)))

Google Sheets, Sort table based on unique values in a single column

I am currently trying to use google sheets to sort a table based on the unique values found in only two of the columns.
What I want to happen is that columns A (Brand) and B (Dimensions) are both checked for unique values, removing any duplicate data.
The problem is using these two columns to filter and show the rest of table. I can't managed to achieve it.
Original Data
What is should look like after being culled
.
You can use Query function:
=query(A1:D8,"select A, B, min(C), min(D) group by A, B",1)
Example spreadsheet
try:
=ARRAYFORMULA(SORT(SPLIT(TRANSPOSE(QUERY(TRANSPOSE(SORTN(
IF(A2:C<>"", {"♦"&A2:A&"♦"&B2:B, "♦"&C2:D}, ), 99^99, 2, 1, 1))
,,99^99)), "♦"), 2, 1))

Referencing from table with mixed cells of different categories

I'm trying to program a Google Sheets for comparing and analyzing logistic costs.
I have the following:
A sheet with a database of numbers, organized like this:
A second sheet with a table in which, using the MIN function, I get the price of the cheapest provider for each model, depending on quantity and destination.
And last, into another sheet, I have what I call "The interface". Using an INDEX MATCH MATCH formula, I let the user choose destination and quantity for each one of the models avalable, and it returns the cheapest price. (I can't post more images, so basically it has this structure):
MODEL A
DESTINATION: DESTINATION 2
NUM. OBJ: 2
PRICE: 59
PROVIDER:
My problem is that I can't figure how to make it return the name of the provider with the cheapest price, as I'm referencing from the second table, in which in a same row or column there are cells with prices that belong to different providers.
Using min is undesirable in this context, because it doesn't tell you where the minimal value was found, and you need this information.
Here is a formula that returns the minimal cost together with the provider. In my example, the data is in the range A1:E7, as below; destination is in G1 and model is in G2.
=iferror(array_constrain(sort({filter(A1:A7, B1:B7=G2), filter(filter(C1:E7, B1:B7=G2), C1:E1=G1)}, 2, True), 1, 2), "Not found")
The same with linebreaks for readability:
=iferror(
array_constrain(
sort(
{
filter(A1:A7, B1:B7 = G2),
filter(filter(C1:E7, B1:B7 = G2), C1:E1 = G1)
},
2, True),
1, 2),
"Not found")
Explanation:
filtering by B1:B7 = G2 means keeping only the rows with the desired model
filtering by C1:E1 = G1 means keeping only the column with desired destination
{ , } means putting two parts of a filtered table together: column A, and column with destination
sort by 2nd column (price), in ascending order (true)
array_constrain keeps only the first row in this sort; that is, one with lowest price.
iferror is in case there is no such destination or model in the table. Then the function returns "not found".
Example: with G1 = Destination 1 and G2 = A, the formula returns
Provider 2 2

Finding duplicates based on first n characters of a string in PL/SQL

I'm new to the forum and SQL, and I'm hoping this will be an easy question to answer. I am working with an Oracle db, and I am wanting to search for duplicate companies in a table by only searching on the first 10 or so characters in the company name string.
For example: if I have 'ABC Corp', 'ABC Co' and 'ABC Corporation' listed separately in my table, I want to be able to search for 'ABC C' and have all companies returned. Since I am looking for duplicates, I only want to return results where the sub-string occurs more than once. It seems like it should be pretty easy, but I cannot get it to work.
Any suggestions?
Thanks
This gets you a list of all substrings that appear multiple times in the table:
select
substr(name, 0, 6),
count(substr(name, 0, 6))
from test
group by substr(name, 0, 6)
having count(substr(name, 0, 6)) > 1
and this returns a list of companies whose substring appears more than once:
select
name
from test test1
where (
select count(*)
from test
where substr(test.name, 0, 6) = substr(test1.name, 0, 6)) > 1

Data structure for user input of complex nested if-then rules

My application requires the processing of measurement data in part via logical rules that are unknown while coding and will be input manually by the user. An example of such a rule is
IF ( Column_3 < 4.5 ) AND ( ( Column_5 > 3.2 ) OR ( Column_7 <= 0 ) ) THEN Result = 2
where the number of elementary comparisons and the bracketing is, a priori, unknown.
This leads to a design question: What is the most efficient way to allow the user to enter this information in a GUI and how can I represent this information in my program in the best way in order to actually compute the whole IF clause? Actually, I would like to represent the rule in an SQL database and so I need a specific data structure.
Thank you all for your kind help!
Regarding GUI, I feel comfortable with entering the data in text-area box.
Unless your common condition are more than 2-3 lines long it should be ok.
The data structure can be something similar to the below design:
Base_Conditions table
ID
Left_operand
Operator_code (> = <)
Right_operand
Logical_conditions table
ID
Left_condition_id
Left_condition_type ("1" for base condition or "2" for another logical condition)
Operator_code (and/or)
Right_condition_id
Right_condition_type
Rules table
ID
Condition_id
Result_action
To store the condition in a relational DB, the data structure would be something similar to this:
Base_Conditions
[1, Column_3, <, 4.5]
[2, Column_5, >, 3.2]
[3, Column_7, <=, 0]
Logical_conditions
[1, 2, 1, OR, 3, 1]
[2, 1, 1, AND, 1, 2]
Rules
[1, 2, "Result = 2"]

Resources