Auto Sorting Sheets Based on Values - google-apps-script

I'm creating a rudimentary inventory tracking system. I first want anything with a value greater than zero to appear at the top of the sheet (current inventory), and then I want all of those rows to be "sub-sorted" alphabetically. I successfully auto-sorted my sheet by two separate columns using the script in this link:
https://www.idiotinside.com/2018/06/08/sort-multiple-columns-google-sheets-apps-script/
However, I want one of the columns to be sorted by a value (greater than zero). I've been searching the stacks and haven't found anything related. I searched the script library, as well, but new to this, so may not have searched properly.
Any help much appreciated!

Related

Syncing a List between different sheets keeping properties sticked to a row

Maybe the title is not explicit enough, but what do I want to achieve, is:
I want to have a single place to edit a list (customers) with some metadata, to be used across the entire spreadsheet.
Some sheets may contain editable data as rows tied to the 1st column with the customer Ids. E.g. prices for services for each Customer for each month.
So, when I add an entry (Customer) to the 1st (master) sheet, it appears in the pricing table and doesn't break the existing entries (the rows remain connected).
So far I've not found any native solution for this. Should I look for extensions fo this, or code it using the app script?

GoogleSheets - How to A-Z Sort Data Pulled by (Filter(Importrange

Here is a link to my sheet. https://docs.google.com/spreadsheets/d/113PRiJKxz_fIPmIoPID5e2IzrZF9ZptslX06JbIatDE/edit?usp=sharing
I am currently attempting to sort data pulled from another sheet into the one linked above by using filter(importrange.
What I have is a list of websites(Col2) with associated data points pulled in different adjacent columns. I have pulled a list of websites into this sheet using filter(importrange.
I have then pulled all associated data points (13 per website) from the other sheet also using filter(importrange, but making the criteria based upon matching the website within this new sheet to websites within the original list.
The idea is to pull all websites and corresponding data points that meet a certain criteria, in this case all websites that contain the ad network "Content.ad".
I have achieved this but now I am wondering how I will be able to sort this data in the new sheet where the data is being filtered into.
I would like to have the ability to sort the list of websites A-Z based upon the different data points, while having each column rearrange so that each data point remains with its associated website while being sorted.
For example if I want to sort the list from A-Z by Traffic Volume, I would like all data points to sort according to the position of their associate website.
Apologies if I have explained this inadequately.
Any help greatly appreciated.

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.

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.