Can I create a List Generator based on specific Data Criteria - google-apps-script

I have a workbook that contains a comprehensive list of Test Scenarios my developers are responsible for. In the workbook I would like to create a "generator" that will return a complete list of tests that need to be completed based on a specific criteria.
Criteria List. When a specific answer is selected on Sheet2 it correlates to a specific column on Sheet3, and I want to populate all rows associated with that answer AND remove duplicates onto Sheet1.
For example If B2 in Sheet2 is Yes, then I want to return all rows from Sheet3 where YES appears in Column D but if Sheet2!B2 is No, I want to return all rows where No appears in Sheet3!D.
I can successfully queue an individual line/criteria using ARRAYFORMULA(IF(TestCaseGenerator!B2="YES", IF(Disputes1!D:D="YES",Disputes1!A:M,""),""))
But I have tried several =ARRAYFORMULA, =IFS, =QUERY combinations and as I stack the criteria the formula breaks; I get one of two errors:
a parse erorr and as of yet cannot determine where exactly the formula is breaking down
Not enough arguments
I know a script may be a better option, but have not written many scripts and am unsure where to even start.

Related

google sheets query first row mess

I am designing a workflow at work to streamline some tasks. I get some CSV from a database which I want automatically added to a Google Sheet. I stored it on a Google Drive, got the direct download link and used it with IMPORTDATA on sheet1. So far so good.
The final aim is to create a good way to visualize which rows meet specific conditions, so I thought using a PivotTable might be handy. However, to filter out some of the uninteresting rows, PivotTables are not the way to go, since the filters are quite poor (no possibility of basic filter criteria like =, !=, <, >, etc). So I thought about populating a second sheet with a Query function (with the filtering statements) so that the PivotTable generates a report directly from a filtered source.
The issue (apart from the lag) is that sheet 2 (the one with the query) shows a strange output: the first row, that should contain only the column labels, mixes up the column labels with the value of the cell below them. It is quite baffling. Moreso because it does not happen all along row 1, but it only appears to do so on the first seven columns. So insted of A1 showing "event_id", it actually shows "event_id 106727", which is the value of the fisrt event that should go on A2.
Any thought why this happens?I already checked and there does not seem to be anything wrong with the CSV.
If yyou also have a suggestion of why this whole setup would be a bad idea, please also tell me :P
Thank you!
The query command combines multiple header rows into one. And sometimes it mistakes your data for headers. To avoid this, use the optional third parameter to specify the number of header rows:
=query(range, query_string, 1)
(if there is one header row).
The approach by #user6655984 did not work for me, because I was already using the third parameter to customise my header usage.
What occurred was that I was performing 12 queries to different sheets with similarly data. One column was a mixture of strings, such as "12 FPS", "14fps", and numbers. When I began working my way through these columns on all the sheets, I was left with mostly numbers, with a few strings spread throughout.
This caused my query to create a massive first row which concatenated the results of about 6 rows together, cell by cell, before showing the rest of the results, where in this column I edited, all the strings had been removed.
By happenstance I saw this one person here who talked about fixing a query issue by making sure that they type-converted the information in a column to be consistent.
This led me to find the following Google support forum post, about queries and data types, from 2019: Query function not working with specific data set (but working with others)
Giving this a go, I tried turning all the data in all the columns that were equivalent to each other in each sheet I was querying into numbers fixed the issue. Try this if setting headers is not working; make sure you don't have silent type errors.

Imported range time values dont match source range time values Google sheets script

I have simple google spreadsheet with two sheets: sheet1 and sheet2. In sheet2 there are time values in column A which I am trying to copy to column A in sheet2. I wrote a script(please see link) for it but values are not the same. What class/method do I need to use in order to get same values in both sheets.
I noticed if I format column A values in sheet2 to text than I get matching values but problem is I am not allowed to that and that column must remain formatted as time.
Also, my second question(please ignore if its off topic). If I have work schedule in google sheet for 3 employees: John,Peter and Mike and they all have editing permissions. If Mike decides to use filter to filter out just his work schedule, is it possible for other two employees to have unedited sheet(as I believe Mike's actions will affect other two persons). What I mean is, is it possible to restrict one persons actions just to view he is looking at while other have unaffected version(together work schedule in this case)?
link for spreadsheet:
https://docs.google.com/spreadsheets/d/1tOtwzM0CxDHBXzC8ECeXlfaTGC4i7rH2XMYYszqRINM/edit?usp=sharing
Much appreciated.
not entirely sure what the problem is, your script is working as intended and you have the same values in sheet1 as in sheet2. The only difference is that in Sheet1 you have a date format and on sheet2 you only indicate the time. I have changed the number format in the sheet1 and as you can see it's the same.
The problem you are having is that by indicating only the time, you let the sheet assume any date. For time it's not that big a deal, but you must be sure that time formats are the same. use getNumberFormat() and setNumberFormat() (read here) to set the correct formats when copying or have the formatting set in advance
As for filtering — you can simply give them view-only access and let them use filtere views (right under "Filter"). A filter will hide information for everyone on the sheet, while a filter view will only be visible to that person. You can also pre-set filter views for them as those with edit access can save filter views.

Merge two ranges into one range using query function in Google Spreadsheets

Please refer to my sample spreadsheet.
Basically this is for cleaning up form responses. There are two sets of identical questions in two different sections, results in two ranges. I wanted to merge them into one while retaining their order, dynamically.
=query({sheet1!A2:F999;sheet1!G2:L999},"select * where Col1 <> ''",0)
This is my try which merged the two ranges in sheet1 but it pulled data from range A2:F999 first, then from G2:L999, messing up the order. Is there any other way to merge them?
you can simply use if, in my opinion, as such
=arrayformula(if(isblank(sheet1!A2:F),sheet1!G2:L,sheet1!A2:F))
Btw, you don't need to use ranges as A2:F999. If you want to say "until the end of file" you can omit the row numbers, and simply use it as A2:F

Compare one column in excel to another column in excel and find duplicate values

I was just wondering if there was an easy way in Excel to complete the following task:
In my Excel spreadsheet I have two tabs. One tab represents one database and the other tab represents a different database. I have a column of data that is 1500+ rows long from my first database(tab) that looks like this:
In the other tab, I have another column that is similar to the above column. My goal is to be able to compare the above column to the other column in the separate tab, and search for duplicate values.
So for example the first code in the above column is 00064. It would search the specified column in the separate tab for the code 00064. If it finds it I would need to be alerted or have it logged somehow. Then it would move on to the next code, 00368 and repeat the process for every cell inside that column. I hope this makes sense. Please feel free to ask any questions you may have for further clarification.
My desired outcome is to ween out the duplicate values but I am not sure how to go about this because due to the length of my columns, manual comparisons would take quite some time. If there is a macro that could accomplish this it would make my life so much easier.
I greatly appreciate any help that can be offered.
Thank you!
-Dave
No need for VBA here. In the first cell of your second column (B1) of your first tab use a countif formula:
=countif(tab2!A:A, A1)
Copy this formula down so it is next to every populated cell in Column A. This will return the number of records in Tab2 that are equal to A1 in your first tab. Look for anything > 0 to find things that have a match, or things > 2 for duplicates.
You can extend this with an if statement like
=if(countif(tab2!A:A, A1)>2, "Duplicate", countif(tab2!A:A, A1)=1, "Only one Match", "No Match"))
This does not require the use of a macro. I would use a VLOOKUP formula. If an exact match is found between the columns it will return the columns value. If no match is found the cell will read #N/A.
An example of the formula that compares the cell A1 on Sheet1 to the column A on Sheet2 looks like this:
=VLOOKUP(A1,Sheet2!A:A,1,)
Here is documentation on how to use this formula.

Extracting Values from 300 sheets where vlookup doesn't work

I have an excel spreadsheet which has just under 300 sheets in it. The first sheet has a list of items which are all numbered 1.1.1, 1.1.2 etc. The rest of the sheets have some of the items listed on them and not in numerical order. I am trying to extract the quantity and total listed against these items on all the different sheets.
The sheets are complicated by the fact that they are not well structure so have section titles which are across merged cells.
I could get this information by hand using the search facility in excel and visit each instance of the number and then add up all the quantities and totals by hand. Is there any way I can automate this? i.e. by asking excel to take each unique identifier from sheet 1, find it in the rest of the sheets and return the quantity and/or total?
I tried using vlookup but it only seemed to return one of the values and ignore all the others.
Even if there was a formula that I had to change the unique identifier by hand that would be much quicker!
Thank you for any help you can give. I am not a programmer so constructing the vb by myself would probably take longer than doing it by hand!
If you add a $ before your lookup data for example
search - $A&2:&AZ&1000
then you are telling excel to look for anything in that array.
because if you do not have a $ in and you copy it, it starts excluding everything above that.