here I have a sheet which have to give two results. one result is working fine but I stuck in finding the next one. in the sheet below I receive products from two suppliers, I want to see which are the new products given by 'second supplier'. And that is working fine. you can see the result in the 'Output tab'(one of you from this platform helped me for that). but my current issue is 90% of the products which supplied from both is same. if the products which 'second supplier' gives matches the products got from 'first supplier' it wont display in Output. but if 'second supplier' gives the lowest price than 'first supplier' then we can't miss that product, it must appear in the 'Output tab' along with the new products. the eg of how the output must be is there in the 'Est Output' tab
https://docs.google.com/spreadsheets/d/19qDWicrqoNiltT1VJE6GdOMTHmjL-GT5YOmHJEh46hc/edit#gid=502304505
any type of help would be appreciable.
Note : if it is not possible then pls display the products with lowest price in the another tab.
I have added a new sheet ("Erik Help") with the following formula in A2:
=ArrayFormula(QUERY(IF('Second Supplier'!B2:B<IFERROR(VLOOKUP('Second Supplier'!A2:A,'First Supplier'!A2:B,2,FALSE),9^9),'Second Supplier'!A2:B,),"Select * WHERE Col2 >0",0))
Here, the formula checks the price of 'Second Supplier' against the price of 'First Supplier'. If it is less, the 'Second Supplier' item and price are returned. If it returns an error, it means that the 'Second Supplier' item was not found in the 'First Supplier' list; in this case, IFERROR still returns the 'Second Supplier' item and price (because it means it is unique). If neither of these is true, then null is returned (which is accomplished by the comma with nothing after it).
TRIM makes sure you don't have any entries of stray spaces (which you currently do have).
Finally, QUERY trims the list of any null entries.
ADDENDUM (based on additional comments)
To show only entries where second supplier's product is new or differs from first supplier's price by more than 2%:
=ArrayFormula(QUERY(IF('Second Supplier'!B2:B<=IFERROR(VLOOKUP('Second Supplier'!A2:A,'First Supplier'!A2:B,2,FALSE)*97%,9^9),'Second Supplier'!A2:B,),"Select * WHERE Col2 > 0",0))
ADDENDUM 2 (based on more additional comments)
This will compare Supplier 2 to the most recent Supplier 1 data by using SORT to sort Supplier 1 data in reverse order by ROW.
=ArrayFormula(QUERY(IF('Second Supplier'!B2:B<=IFERROR(VLOOKUP('Second Supplier'!A2:A,SORT('First Supplier'!A2:B,ROW('First Supplier'!A2:A),0),2,FALSE)*98%,9^9),'Second Supplier'!A2:B,),"Select * WHERE Col2 > 0",0))
Related
Hello stack overflowers.
I have recently been creating a nutrition tracker to better track and control my nutrition. However I have run into an issue. So currently I have a 1 sheet in the nutrition tracker which is a "database" of foods and their macro nutrients per gram. In this sheet, I will enter all the foods that I generally eat and their associated per G nutrients.
this food "database" sheet has the following columns.
FOOD NAME, CALORIES, PROTEIN, CARBS, OF WHICH SUGARS, FAT, OF WHICH SATURATED, FIBER, SALT
This database is then used as a reference, so that when I input each meal as I eat it, I can simply select the food from a drop down list and type the number of G in that meal, and the nutrients will all be calculated for me.
I currently have it setup so that I can select food from the drop down list generated by "foods" sheet, within each meal table I have created. This is then correctly filling in the rest of the columns as expected once I input a weight for each meal. There is however a huge problem.
As soon as the FOOD NAME column of the Foods sheet had values in it below row 7 (not sure why this row is the limit) the whole thing stops working, the data grabs based on VLOOKUP just return 0 and do not act as they are meant to. The strange thing is they work absolutely fine until I enter too many foods (7 foods) into the foods sheet.
Please find below a link to my spreadsheet, maybe you can duplicate it and play around a little yourselves to better understand the issue.
https://docs.google.com/spreadsheets/d/1orwih7s_Z4ew8G1vJcR6qlxyMpX8pqK-3Ynj42qQjcQ/edit?usp=sharing
(if you help me fix it, you will have a free nutrition tracking spreadsheet to help you take control of your diet aswell)
Thanks in advance.
In the June tab, clear all formulas in the range D11:K18.
Then enter in D11
=ArrayFormula(IF(LEN(B11:B18), IFERROR(VLOOKUP(B11:B18, FOODS!A:I, {2, 3, 4, 5, 6, 7}, 0)),))
This single formula will process all values entered in B11:B18.
Note the third parameter of VLOOKUP (set to false). If it is ommitted (as in your formula) it will default to 'true'. That means vlookup expects a 'sorted order' which may not be the case for your data.
References
VLOOKUP
try:
=INDEX(IF(B11:B18="";; IFNA(VLOOKUP(B11:B18; FOODS!A:I; COLUMN(B:G); ))))
Working on a spreadsheet to list inventory items for sale in bulk. Wanting it to automatically generate a "Condition Note" for each item based on it's SKU and Category.
Have a sheet named "Description Table" that has Condition Notes arranged by Category (row) and Condition (column.) The last 2 digits of the item's SKU determine its condition.
This is the formula I have so far, but it's giving an error that it's not finding the row in the MATCH evaluation, specifically "Did not find value '43' in MATCH evaluation." 43 is located in A6 of the Description Table sheet. Any ideas?
=INDEX('Description Table'!A1:J23,MATCH(RIGHT(C2,2),'Description Table'!A:A,0),MATCH(B2,'Description Table'!1:1,0))
Here's the spreadsheet: https://docs.google.com/spreadsheets/d/1SBtJicsKlxykBfKwwLyeHV__ope-D1lciA8X2FD3CKo/edit?usp=sharing
You can't match the string "43" with the number 43. You need to convert the string to a number:
=INDEX('Description Table'!A1:J23,MATCH(value(RIGHT(C2,2)),'Description Table'!A:A,0),MATCH(B2,'Description Table'!1:1,0))
use:
=ARRAYFORMULA(IFNA(VLOOKUP(RIGHT(C2:C, 2)*1, 'Description Table'!A3:K,
MATCH(B2:B, 'Description Table'!A1:K1, 0), 0)))
Let's say I have three columns. Column A has a list of names (that are repeated), column B has the city they live in, and column C has the number of pets.
I can use the unique(A1:A5000) function to get the list of unique names. However, I want a list of the unique names for people who live in New York and have Zero pets.
I can use:
COUNTUNIQUE(FILTER(A1:A5000,B1:B5000 = "New York",C1:C5000=0))
To get the number of unique people who live in new york and have zero pets, but I want to get a list of unique names.
Basically I want to combine the "unique" and "if" features and I'm not sure how to do that.
I would be open to doing this in two steps: Step 1: Get a column with all the names of people who satisfy this condition Step 2: Get the unique names in that column. But I'm not sure how to do step 1.
Please try:
=query(A:C,"Select A where B contains 'New York' and C=0")
I am looking for a formula that can perform the "COUNT" equivalent of "SUMIF". I have in 'Sheet A' running records of attendance, with column A as "Last Name," column B is "First Name," and column C is "Attendance." The attendance column has values of "P, A, L" for present, absent, or late (respectively). The sheet is automatically updated each day, as new data for the day's attendance are appended at the bottom of the sheet.
In 'Sheet B' I have each student's name, matching the syntax in the above sheet ("Last Name" "First Name"). In this sheet, I want to be able to count the number of instances of each, "P", "A", and "L".
So...I want to be able to count in Sheet A the number of times a student has a "A" in the attendance column, conditionally by student name. I know that with SUMIF you can sum a range conditionally. COUNTIF does not work to appropriately filter the values by the student name. I was not able to get DCOUNTA to work either.
Open to any suggestions, no matter how complex.
For anyone curious, I came up with my own crude solution.
I created a new sheet for each: Present, Absent Late. Within each sheet I ran a query: =QUERY({'Imported Data'!A:C}, "select * where Col3 = 'P'"). This query returned every record where an individual was marked "P". Repeat for "A" and "L" on their respective sheets.
In my main sheet, which records count totals, I used the COUNTIF: =COUNTIF(Present!D:D,C2). I had a small problem to work around in this, as I had my data imported with a "Last Name" and "First Name" column, but could not COUNTIF across two columns. So, I created an ARRAYFORMULA in each Present/Absent/Late sheet. This concatenated the name values, so I could search against that singular value in my main sheet. This was present in D:1 of Present/Absent/Late: =Arrayformula(A:A&", "&B:B).
A little duplication and I was able to create my own, automatically updated, attendance tracker.
You seem to have gone to a great deal of effort to work around a problem that does not exist. In general, where SUMIF works for adding then a very similar COUNTIF should work for counting. Because in most groups of modest size neither first names nor surnames are likely to be unique (even if the combinations are likely to be) it is generally a good idea to assign IDs to people. Concatenating Last Name with First Name is effective but other options can be more compact.
Assuming in Sheet B you have P, A and L respectively in C1:E1 (a unique set of Last Name in ColumnA and First Name in ColumnB) then in C2 the following may be adequate if copied across to E2 and C2:E2 down to suit:
=COUNTIFS('Sheet A'!$A:$A,$A2,'Sheet A'!$B:$B,$B2,'Sheet A'!$C:$C,C$1)
Sheets Imported Data and Present seem irrelevant.
I'm trying to make a database of students using Google Sheets. It contains info about students, groups and orders; orders can change students membership in groups (taken in a group, moved up to a new group, graduated, on leave, sent down). Here are sample database sheets and here is a detailed description of my DB structure (the sheet report_Groups is slightly changed, its previous variant, described on the link, is now named old_report_Groups).
I need a query that would select a list of present members of given group on the given date. That means that for each student I have to select
the name, the latter status before given date and corresponding group. And from this result select student names, where statuses are "Taken in" or "Moved Up" and group is the same as given one.
The problem is to select the latter status. It should be MAX(status), whose "since" date ≤ given date, but there's a well-known problem of selecting more than one field together with aggregate function. Here is a question which is very close to, but query from its "best" answer gives me error "QUERY:NO_COLUMN". I've even copied the sheet Raw from there and tried to perform proposed query (with the onliest modification — replacing commas with semicolons according to my locale restrictions) on the data it was reported to work on — same error (check Raw and report_Raw sheets in my DB). Other variant (via MMULT and TRANSPOSE) works, but it's perfomance is very poor.
What can you suggest me? Thanks in advance.
Update: I've found the solution with an issue (described in my answer).
To solve the issue I need to know an answer for a different question.
Here's the solution (with an issue described below).
A. Orders_Students is filtered for selecting rows, having "since" cell value ≤ given date (report_Groups!A2):
=QUERY(Orders_Students!B:E;"select E, B, C, D where E <= date '" & TEXT(report_Groups!A2;"yyyy-MM-dd") & "'";1)
This interim result is stored at the inner_report_Groups tab (it will be referenced few times in the next query).
B. inner_report_Groups is filtered for selecting MAX("since") values and corresponding row cell values for each student:
ARRAYFORMULA(VLOOKUP(QUERY({ROW(inner_report_Groups!A$2:A)\SORT(inner_report_Groups!A$2:D)};"select max(Col1) group by Col3 label max(Col1)''";0);{ROW(inner_report_Groups!A$2:A)\SORT(inner_report_Groups!A$2:D)};{3\4\5};0)
The formula above is used as inner query in report_Groups!D2 (also in D3, D4—with appropriate indeces).
C. The second query result is filtered to get students whose status is either "Taken in" or "Moved Up" and corresponding group is equal to the given group (report_Groups!B2 (also in B3, B4—with appropriate indeces)):
=TRANSPOSE(IFERROR(QUERY(<here is the formula from step B>);"select Col1 where Col3 = '" & B2 & "' and (Col2='Taken in' or Col2='Moved Up')";0)))
The formula above is used as outer query in report_Groups!D2 (also in D3, D4—with appropriate indeces). IFERROR is intended to display nothing if query result is #N/A.
That query displays the needed results as you can see in report_Groups tab. But as the query on step B searches the whole columns of inner_report_Groups, there's only a single given date can be analysed (or the query interim results for other given dates should be placed in different columns of inner_report_Groups or at the different tab. Is there any way to give an alias for an interim result to refer it in a single cell formula instead of keeping it on different tab?