Google Sheets combining REDUCE & FILTER to compare and extract data from one spreadsheet to another - arrays

I have been struggling with a problem for a few weeks now and after trying to solve it myself I come cap in hand for help.
I have tried to use QUERY and ARRAYFORMULA and quite a few other formulas, but I can't crack it.
I have 3 workbooks that need to work together.
Product Catalogue - holds a list of each product type and the components that go into it (like a recipe).
Schedule - This sheet contains tabs for each product and then in each tab is a list of specific iterations of the product.
Components Required - This sheet contains tabs for each component that we require. In each tab cell A1 contains the component number and each tab is named the same as the component number.
What I need to do is compare the Product Catalogue to the Schedule and populate the Components Required sheet tabs with the specific iterations from the schedule.
The data I am working with has many products and over 400 components and over 400 product iterations and the data is confidential.
So I have built some dummy sheets to replicate my challenge. Links above.
My solution has been focused on adding a formula to cell A3 of each Components Required tab, which looks at the component number (cell A1) and searches for this component number in the Product Catalogue. In most cases, it will find the component listed several times against several Products. Once it has found all the Products, it needs to look up those products in the Schedule and then import the full list of specific iterations from each of the products into row A of that Components Required tab.
In the Components Required sheet the first tab is an example of how I would like the data to look once imported, it has been manually copy/pasted by me to demonstrate the outcome.
Any help that anyone can offer would be gratefully recieved.
Thanks
Tim

I have realised that I was asking too much with my question.
However, I have worked hard on it and have come up with a solution, which may help others in the future.
I welcome feedback on the formula and also my method of answering my own question.
=REDUCE("Product Code",
FILTER(importrange("1J_8v2biODyIwsV9f2F6gLnK0N-bR4Fsokrmd88PfxMg/edit#gid=0","Product Catalogue!$A$2:$A"),importrange("1J_8v2biODyIwsV9f2F6gLnK0N-bR4Fsokrmd88PfxMg/edit#gid=0","Product Catalogue!$B$2:$B") = INDIRECT("A1")),
LAMBDA(a,c, {a;importrange("1gvOZ_GuZx6HOLHQ7WwyIlFHrAihoNXz2ysZkublh7Fs/edit#gid=1198217965",c&"!A2:A"&COUNTA(importrange("1gvOZ_GuZx6HOLHQ7WwyIlFHrAihoNXz2ysZkublh7Fs/edit#gid=1198217965",c&"!A1:A")))}))
The resulting formula can be seen inside the Components required spreadsheet in sheet C0001 cell A2
Thanks for the help I have received from everyone on the forum

Related

How can I sort and map my SQL query in Ionic?

I have a database running in the background, the aim of the whole thing should be that I have categories as buttons and that categories should be created under elements. I separated the whole thing in the database (i.e. in two tables), i.e. in categories and in the sub-elements. I get everything correctly selected but just don't know how to assign or build it. Does anyone have any ideas or examples to look at?
I've already tried Ionic's list system. Just like ion-record.

Pop up window with data from another spreadsheet

I'm trying to build a master spreadsheet in Google Sheets to call up data (not import data, just make a quick view in a popup window) for individuals from other spreadsheets. E.g. my master sheet has a column for therapists, a column for certifications, a column for periodic reviews, etc. All of these columns correspond to other sheets within the project that list out the certifications for each individual therapist, the periodic reviews for each individual therapist, etc.
I want to be able to click in the cell where "Mary" intersects with "Certifications" and see a small popup window that shows me Mary's record in the Certifications page.
I tried a couple of functions pasted from other pages (it's been a long time since I've coded), but none worked. This seems like a simple database-like call, so I hope the solution is also simple. I appreciate any help offered. (My clinic doesn't have an in-house IT person, so I'm trying to help where I can.)

How to add two (or more) tableViewCells together to make a 'total'

I have a tableView that has the price and quantity of an item in the cell, and I want to add these together so if there is multiple items - it will then say the total.
This is in my cellForRowAt
detailCell.priceCostLabel.text = sortedPriceDictionary[indexPath.row]
detailCell.quantityLabel.text = String(sortedQuantityDictionary[indexPath.row])
let totalPrice = (Double(sortedPriceDictionary[indexPath.row])! * Double(sortedQuantityDictionary[indexPath.row]))
print("The total price is \(totalPrice)")
This is working as far as it is printing the correct price for each product and how many of each there are, but if there are 2 or 3 cells, it is printing (for example)
The total price is 3.9
The total price is 20.7
Would I create an array of totalPrice(s) and do arrayOfPrices[0] + arrayOfPrices[1]? Then again how would I know how many cells I need to add together? Thanks in advance.
What you are trying to do is a bit unusual. In the world of Model-View-Controller, I would expect that the list of prices that you are trying to add up would be the Model. If you were to do any calculations on those prices then you would do it as part of the model. The model would know how many prices it has stored and would know how to add them up.
The TableView would just be a means of putting the values from the model on the screen. You would create as many tableViewCells as your model demands and all the "View" part of the MVC triad would do is show them, you wouldn't actually perform calculations on the values in those cells, they're just for display.
I recommend that you read more about the MVC pattern and gain a better understanding of the role of a TableView. You can start with Apple's description:
https://developer.apple.com/library/archive/documentation/General/Conceptual/DevPedia-CocoaCore/MVC.html
When you click on that link it will tell you that that documentation page is deprecated. That's OK. Read it anyway. A Google search of MVC or Model View Controller will provide a rich collection links to help you understand the pattern, and hopefully your problem and solution.

Automation script for website in loop

Below is the screenshot of the web pages, I need to write a script that add the product automatically, suppose 15 times.
I achieved this for one single entry but i need to write it in a loop.
Challenge here is that i need to select different categories based on which there are different sub-categories and based on sub-categories there are different sub-sub-category so can anyone suggest how to achieve this.
If the fields and dropdown itself don't change you can create some kind of collection for each of the category options and sub options. Then with some mapping from one category to other you can achieve this.
Eg. CategoryArray will have [Item1, Item2, Item2] selection of this choice will guide which subcategory array you will access like Item1SubCategoryArray then so on and so forth.

Issues on a select with AngularJS and Google Spreadsheet

I want to create a small web app which would display a list of movies, with a Google spreadsheet set as a database. So far, I was able to connect my spreadsheet to my app and I also added some filters to it. (As a side note, this thread really helped me in the process.)
Here is a very simplified version of my app: http://plnkr.co/edit/BtbSCVOh7KJsMHjANxMP?p=preview
I still have 3 problems with my <select>, which I can't fix despite trying for hours:
I can't sort my <options> alphabetically. Trying with orderBy didn't return anything.
I can't figure out a way to split my categories when there are more than one for a movie.
If the "categorie" field in my spreadsheet is empty, it will return a blank <option> which I would like to remove or hide.
My guess is that I'll need to update my function one way or another, but I'm a bit lost at the moment.
Any help on this would be really appreciated!

Resources