I'm using the IMPORTRANGE() function to import some columns and rows from another sheet.
I have been trying to find a way where if columns/rows in source sheet change, it wouldn't reflect in the original file. Columns/rows could be deleted or added. Is there a way to do this using IMPORTRANGE() function?
I'm only selecting a number of columns from the original file, so if an extra columns gets added columns will get shifted.
I have looked at QUERY() function, but that seems to be static as well, columns are refered to as A,B,C etc too.
The function that I'm currently using is the basic IMPORTRANGE() function.
=IMPORTRANGE("url", "sheet!range")
try not to use column names just raw rows:
=IMPORTRANGE("url", "sheet!1:1000")
Related
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.
I am trying to get to the point where my Google sheet is going to show up like the picture below.
Basically I am trying to find the common column in different table (sheet) and also make sure the type of the columns matches too. The columns are unsorted and won't be of equal length.
But I am unable to do so using vlookup or query which is becoming to complicated. I am attaching the link for the Google sheet.
https://docs.google.com/spreadsheets/d/1yk5J_R74yvYTOmOr5LHgMuLD--xT68pOaps8XvhOgy8/edit#gid=0
Try below formula-
=IFERROR(MAP(C7:C13,D7:D13, LAMBDA(x,y,IF(XLOOKUP(x,A7:A10,B7:B10)=y,"Match","Mismatch in Type"))),"No Match")
This should also work.
=INDEX(IFNA(XLOOKUP(--(VLOOKUP(C7:C13,A7:B10,2,0)=D7:D13),{0,1},{"Type Mismatch","Match"}),"No Match"))
This will spill results automatically. No need drag down.
Update: Use below formula as dynamic input range from source and target sheet without helper QUERY function.
=MAP(Target!A2:INDEX(Target!A2:A,COUNTA(Target!A2:A)),
LAMBDA(x,IFNA(XLOOKUP(XLOOKUP(x,Source!A2:A,Source!B2:B)=XLOOKUP(x,Target!A2:A,Target!B2:B),
{TRUE,FALSE},{"Match","Type Mismatch"}),"No MAtch")))
I think you have a typo in your Source table (you have 'emd_id' where you meant 'emp_id'). If you correct that, you can delete everything in F7 downwards and try the following in F7:
=arrayformula(ifna(if(sign(match(C7:C13,A7:A10,0))=ifna(sign(match(C7:C13&D7:D13,A7:A10&B7:B10,0))),"Match","Mismatch in type"),"No match"))
We are creating two arrays corresponding to whether the 'column' or 'column' AND 'type' entries match in both Source and Target, then using IF/IFNA to assign the required results based on whether the overall result was TRUE/FALSE/#N/A.
EDIT: To make the formula dynamic (as per the comment):
=arrayformula(lambda(source,target,
ifna(if(sign(match(index(target,,1),index(source,,1),0))=ifna(sign(match(index(Target,,1)&index(Target,,2),index(source,,1)&index(source,,2),0))),"Match","Mismatch in type"),"No match"))(
Source!A2:index(Source!B2:B,counta(Source!B2:B)),
Target!A2:index(Target!B2:B,counta(Target!B2:B))))
I have a pivot table, in Google Sheets, and want to add a percentage column.
EDIT: here is a link to a sample spreadsheet: https://docs.google.com/spreadsheets/d/12qyhOtKphW1iBWAOtfDHU1RdZRZ_Nq91eQtdghZzIyc/edit?usp=sharing
Below you can see the pivot table with the column (E) that I've manually added next to it, showing what I want to achieve, but as part of the pivot table, which is a simple:
E4=D4/C4
However, I have tried adding a Calculated Field under Values but can't work out the right formula; this didn't work:
='Checked In'/'Events'
nor did:
=D4/C4
I'm sure it's something simple, but I can't for the life of me work it out. Can anyone shine a light on what I'm doing wrong please?
Short Answer: Only use the column headers of the raw data and not the column headers of the other existing calculated fields.
Note: Since you have not shared a sample spreadsheet, I have made a sample data just to show the process.
Sample Raw Data
Creating a Pivot Table
Select the desired data to be added to the table which only includes the useful column headers (like the one selected in the sample raw data image).
Add a Calculated Field
To add a calculated field, look for the Values section in the Pivot table editor and click add (as shown above). To enter a formula, the pivot table editor requires you to use the column headers instead of the cell range (A1 notation). The formula you provided works just fine. In this case, I used ='Checked in'/Events to check if column headers with one word do not necessarily need single quotation marks (which will result in the following):
Note: Always use 'string' (single quotation mark) format in using column headers especially when the column headers contain spaces (like Checked in in the example).
Note: You may change the Column Header Output just by selecting the cell and renaming it.
Sample Modifications
You may also use other Google Sheets functions in the formula just like:
Which results to:
Reference
Create & Use Pivot Tables
Additional Info
When trying to add additional calculated fields using data based from other calculated fields, always use the original column headers of the raw data and not the column headers of the calculated fields as it returns an error just like the one below:
In your case, I modified your formula to
=COUNTA('Venue Name')/COUNTUNIQUE('Event Date')
Since both Venue Name and Event Date are the column headers of your raw data and not Checked in and Events. The current output of the corrected formula should look like this:
To address the decimals in the output values, you may refer to the Sample Modifications section of this answer.
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).
In Google Sheets, I'm trying to use AVERAGEIF to calculate an average of only some of the columns in another table.
The columns to be included in the average are marked by some text in a specific cell (e.g. the first or last row of that column).
Some columns are to be included in several averages, so the text in the top\bottom row would include several words (effectively meaning I'll need some sort of substring check such as FIND).
I've tried using AVERAGEIF() in conjuction with FIND() but couldn't get this to work.
Any ideas?
Here is an example of how the data sheet looks like, and how I would expect it to work
You can use following formula:
=ARRAYFORMULA(AVERAGE(IF(ISNUMBER(SEARCH(D2,A2:A9)),B2:B9,"")))
Edit:
For table mentioned in comment you must change ranges:
=ARRAYFORMULA(AVERAGE(IF(ISNUMBER(SEARCH(E2,$A$1:$C$1)),$A$2:$C$4,"")))
You can use a query
=AVERAGE(QUERY(TRANSPOSE($A$1:$D),"where Col1 contains '"&D1&"'"))
Functions used:
AVERAGE
QUERY
TRANSPOSE