Connecting dynamic data with input in google sheets - google-sheets

I have gotten lost on a question in Google sheets re aligning dynamic data with static input data. At a high-level my problem is that I have dynamic data being pulled in a sheet where I also add in manual input data. Once the dynamic is changed it also means that the input data no longer corresponds to the right row.
Issue:
Sheet 1: I have an external data pull (Importdata) that dynamically pulls in new data.
Sheet 2: I use Query & Importrange to pull in parts of the data from sheet 1 (i only pull data where certain criteria are met)
Sheet 2: In sheet 2 I manually add data in columns next to the pulled data (J,M,N & O are input). The problem is, that when new data is pulled in from Sheet 1 it is then pulled through to sheet 2 and changes the order of the rows. This means that the manual data I have inputted no longer corresponds to the right rows.
Solution:
I need a way to ensure that the inputted data corresponds with the right row. So if a new row is pulled in the manually inputted data will follow the row where it was initially entered and move up/down with the row.
Sheets:
Link to Sheet 1 & Sheet 2
Really appreciate the help
Best
Palle

I'll attempt what I think is an answer here.
Basically, you need a unique key or identifier for each row of your dynamic data in Sheet1. Possibly, this could be the derivative_id. If not, you need to build a unique key, maybe derivative_id and the date, or some other combination.
Then you need an Update tab, where you would have the key, plus any other info you want to help guide in making your update. And then you have your four manual update columns - currently J, M, N, O in Sheet2.
Finally, Sheet2 becomes all automated - filled by formula only. Columns A:H continue to update dynamically, and all of the others are updated by formula, typically a VLOOKUP, as in column I, or a calculation, as in K and L. And columns J, M, N, and O will now do VLOOKUPS against the Update tab.
So even when Sheet 2 rows are updated or reordered, the "manual" data in J, M,N, and O will still stay with the correct row, since it is tied to a unique key for the data in that row.
If this all makes sense to you, I can put together an example for you.

Related

IMPORTRANGE in Google Sheets preserving the structure of the destination sheet

Suppose that we have the following Google Sheet (called File_1):
And we import all the columns (A to C) via IMPORTRANGE("https://docs.google.com/spreadsheets/...", "Sheet1!A:C") into another sheet (called File_2), which also contains an additional column New_col with some data in it:
Now, suppose that the source sheet changes like this, i.e., a new row is added in-between the existing rows:
The destination sheet will become like this, in essence keeping Column D in its previous state and 'breaking' the relation of the 'test' value in cell D2 with the A1-B1-C1 row.
What I would like to have instead is the following destination sheet:
Is there a way to do that from within Google Sheets?
You are describing how formula results get misaligned with manually entered data. There is no turn-key solution to work around the issue. Lance has given a thorough treatment of the row misalignment issue and how it can be dealt with in some cases.

check for partially filled rows and delete the rows that don't have data in them

I have been working on a google sheet(sheet A) where the data comes from another sheet(sheet B) through importrange. In sheet A, column A contains all the urls, col C is the keywords and col F SEO keywords. I want to implement a function or an app script where for every url in column A, if the data is present in either column C or col F, that row should stay and if for url in column A, the data is col C and F is not present then the row should be deleted and the row below should move up. I am not sure how this should work. Can anyone please help me with the function or app script to be used for the same?
I am not sure I am understanding your question.
So there is an empty B column between A and C column? If so put this in B2 =if(sum(len(C4)+len(F4))>0,A4,"") It'll see if both C&F are empty and if so return a value of blank instead of the URL. You can then just copy-paste values only that over into Column A and you're set right?
From my understanding you want to keep combinations A,C - A,F - A,F,C & omit rows where it is just A as the only value?
If so this should get it done pretty easily. Are you doing this on like 10k+ row sheets?
You will not be able to move around rows with data that was imported with IMPORTRANGE in SheetA.
What you could do is write an Apps Script code to move around the source data in the source sheet since IMPORTRANGE gives you a live overview of the data in the source sheet. This might be the "cleanest" solution. In the source sheet you could have an onEdit trigger sorting your rows so that rows with empty columns are at the bottom. Then you can use IMPORTRANGE to import only the rows where all three columns have the data you want. (Extra careful with using IMPORTRANGE in apps script please, especially when counting rows afterwards due to lag)
Another option would be to just copy the values with a trigger instead of using IMPORTRANGE. This wouldn't be "as live as IMPORTRANGE" though but it would be easier to use the data.
If I understand you correctly, you are importing some data via IMPORTRANGE and you want to remove the imported rows in which columns C and F are empty.
If that's the case, you could use QUERY to filter out the undesired rows in the formula itself, so that they are not imported:
=QUERY(IMPORTRANGE("spreadsheet_url", "sheet_name!range"),"SELECT * WHERE (Col3<>'' or Col6<>'')")
Note:
If you wanted to use a script, the source data should not come from a formula (in that case, you should copy the imported data somewhere else and work with the copied data, which would not depend on the formula).

Google Forms changes cell reference on different sheet in Google Sheets

I'm building a spreadsheet to track my macronutrients and calories. I made a google form for inputting information and it populates a "responses" sheet on google sheets. I made a different sheet within the same spreadsheet to perform all the calculation and generate graphs.
But every time I enter a new response into the form, it creates a new row and changes all the cell references in the calculations sheet. For example, I reference cell A2 from the responses
='Form Responses'!A2
and when I actually fill out the form and it populates, A2 in the responses sheet is filled in but the reference in my calculations sheet has been changed to A3.
='Form Responses'!A3
I tried using $ but it did the same thing, automatically changes the cell that I referenced.
Any way to have my calcuations sheet reference the newly created rows automatically?
In a new tab use for example, = {'Form Responses'! A: Z} and use this data to do your calculations and you will have no problems!
Solution
To avoid the row value to change reference when adding a new response, you will need to add the $ next to the number instead of next to the column value (A):
='Form Responses'!A$2
Moreover, an easy way to reference your whole column is to reference a range instead such as:
='Form Responses'!A:A
And then just drag it through your column. If you want it to be more specific (select the range you want):
='Form Responses'!A2:A999
I hope this has helped you. Let me know if you need anything else or if you did not understood something. :)

Setting formula range from first to last populated cell in a column?

For a league I run we keep track of games played and w/l/t and calculate that into a ranking score. The player name is listed in column U and the ranking score in column AD of a fixed table. I then use an array formula to list the players in ranking order in column E (then vlookup to pull in other stats based on the value in E for that row). Specifically I use this formula in column E:
=ARRAY_CONSTRAIN(ARRAYFORMULA(INDEX($U$4:$U$153,MATCH(LARGE($AD$4:$AD$153-ROW($AD$4:$AD$153)/COUNT($AD$4:$AD$153),ROW(E72)-ROW(E$4)+1),$AD$4:$AD$153-ROW($AD$4:$AD$153)/COUNT($AD$4:$AD$153),0))), 1, 1)
I need to be able to add players to the table in U:AD without having to edit the formula every time, i.e. from $U4:$U153 and $AD$4:$AD$153 to $U4:$U154 and $AD$4:$AD$154 in all the various places in the formula then copy the new formula all the way down.
Is there a way that I could define the range as $U$4:$U(last populated row) and the same for column AD in the above formula?
I eventually be using this in both Excel and Google Sheets so I would really like to avoid scripting. First I'm looking to solve this for Google Sheets.
Here is a copy of the sheet I am working on.
You could use INDEX and COUNTA
Instead of $U4$U153,
$U4:INDEX(U4:U,COUNTA(A4:A))
The COUNTA portion will give the number of populated rows and feed it into INDEX to give $U4:$U153
The answer for the Google sheet that you shared.
skip to the end for the simple solution
I used the indirect method by entering a formula in E1 that counts the AD column for player stats and adds 3 to get the last row. (I was going create the full range AD4:AD?? but you also have U4:U73 in the formula)
=counta(AD4:AD)+3
I then changed your formula use indirect, indirect("$AD$4:AD"&E$1), to reference the last row number in cell E1 to create the required range.
=iferror(ARRAY_CONSTRAIN(ARRAYFORMULA(INDEX(indirect("$U$4:U"&E$1),MATCH(LARGE(indirect("$AD$4:AD"&E$1)-ROW(indirect("$AD$4:AD"&E$1))/COUNT(indirect("$AD$4:$AD"&E$1)),ROW(E4)-ROW(E$4)+1),indirect("$AD$4:$AD"&E$1)-ROW(indirect("$AD$4:$AD"&E$1))/COUNT(indirect("$AD$4:AD"&E$1)),0))), 1, 1),"")
I discovered by accident that if you remove the ARRAY_CONSTRAIN from your formula and change U4:U73 to U4:AC73 then the formula will populate the scores to the right of your formula where you currently have vlookups. I put an example of this in E4 but note that you will have to delete the vlookup formulas if you want to fill the formula down otherwise it will show REF
I also added iferror so that the formula can be copied to the same row as the end of the "open slots" in column A without showing errors.
Also, I got to this point and was thinking that since you're using Google Sheets, a better way to do this could be to use the QUERY function to pull the data and also sort it using ORDER BY with a single formula in cell E4.
I've not really used the QUERY function but maybe it's time to learn.
EDIT
Turns out it doesn't take much learning
=QUERY(U4:AD,"SELECT U,V,W,X,Y,Z,AA,AB,AC ORDER BY AD DESC")
Put the formula above in cell E4 and delete everything beneath and scores to the right and you're done. you'll notice that there is no indirect because Google understands that you don't want the blank rows.
https://docs.google.com/spreadsheets/d/16IclEmKwDFdInIAZhH2vt-tLJ5pbwX06jv9xrUXwhnY/edit?usp=sharing
Why are you using $ signs around U4:U153,remove $ signs for rows that will give you flexibility while keeping columns fixed.As your drag the formula,the data array will append the newly filled cells or you can create table using Ctrl+T that will automatically expand as you keeping adding data.

Number increment in Google Sheets formula

In a Google Sheets database, I have a formula which I have built in order to allocate a reference number to a series of companies.
Each company should have its unique number in the form of RET00XX where XX will represent the unique company number. I would like these numbers to be sequential, starting on 1 and going on +1 after that.
Whenever a new company is inserted in the database, the formula should be able to attribute it a reference number. It should also be able to verify if the company already exists in the database and, if so, automatically attribute it the company's unique reference number, instead of creating a new one.
The company names are in cells of column B.
This is the formula I have built (an example of the one in row 2):
=ARRAYFORMULA(IF($B2<>"",IF((COUNTIF($B$1:$B1,$B2)>0),INDEX($A$1:$R2,MATCH($B2,$B$1:$B1,0),12),CONCATENATE("RET00",ROW($B2))),""))
The steps it takes are:
It verifies that column B in the correspondent row is not empty;
With the COUNTIF function, verifies that the company does not exist in any of the previous rows;
If the company does exist, it attributes the correspondent reference number through the INDEX function;
If the company doesn't exist, it attributes the company a new reference number with the CONCATENATE and ROW functions.
The formula is largely working, although there are some problems.
Users adding to this database have the habit of adding entries by inserting rows in the middle of the database. This makes it so, due to the way the formula is built, that company unique reference codes change each time that happens. I believe this is partially due to the fact that I use a ROW function. Also, given that new rows are inserted in the middle of the database, the formula should be able to verify is the company already exists not only by looping through all previous rows but rather through all rows (if a new row is inserted, the formula will only verify previous rows, when the company could be in the rows after the new one).
How can I attribute sequential numbers in a formula without reference to ROW? Also, how can I make sure that the spreadsheet verifies for all rows of column B instead of just the ones before the inserted row?
apply this formula in your sheets,
=ArrayFormula(if(B2:B<>"",row(A2:A)-1,""))
More information regarding this please visit this link : https://infoinspired.com/google-docs/spreadsheet/auto-serial-numbering-in-google-sheets/
Solution that is independent of starting row number
These examples will allow you to generate incrementing values in your formulas.
Incrementing integers, zero based:
The values will be: 0,1,2,3, etc.
Note: The address "$A$2" represents the cell of your top row. It should be changed to whatever cell your actual top row is. The nice thing about this method is it it will not break if you insert new rows above the start position of your formula.
=(ROW()-ROW($A$2))
Integers, one based:
The values will be: 1,2,3,4, etc.
=(ROW()-ROW($A$2) + 1)
Dates:
The values will be: 2000-01-01,2000-01-02,2000-01-03, etc.
=Date(2000,1,1) + (ROW()-ROW($A$2))
All Even Numbers:
The values will be: 0,2,4, etc.
=(ROW()-ROW($A$2) * 2
Short answer
Use Google Apps Script
Explanation
Using spreadsheet functions to set an ID on a live spreadsheet used as a database is very risky as the values will be recalculated when changes be made to the spreadsheet content.
Instead of using a formula use a script to add a "fixed value". Scripts could be called automatically on events like cell edits and row insertion, by using a custom menu or side panel, from the script editor or by time-driven triggers.
The following Q&A from Web Applications shows several ways to set a sequential number:
Can I add an autoincrement field to a Google Spreadsheet based on a Google Form?
This other from SO could be helpful too:
Auto incrementing Job Reference
Insert 1 in the first cell and paste the formula below in the following cells.
=INDIRECT(ADDRESS(ROW()-1,COLUMN())) + 1
Add number on very first row and type the formula from next cell
i used =A1+1 to get incremental number to index tasks on each line.

Resources