I'm trying to do a lookup based on 2 criteria to match on another sheet and return a value from the last match that it finds.
I've been able to get this logic working with a single criteria:
=INDEX('Rank History'!B:E, MAX(filter(ROW('Rank History'!E:E), 'Rank History'!E:E=C3)),3)
and I've been able to do it with multiple criteria:
=INDEX('Rank History'!D:D, MATCH(1, (B3='Rank History'!B:B) * (C3='Rank History'!E:E), 0))
How do I tie these two approaches together?
Try this:
=INDEX('Rank History'!D:D, MATCH(2, 1 / ((B3='Rank History'!B:B) * (C3='Rank History'!E:E))))
I know that through
select cases if char.substr(variable_name,1,3)="I22".
I can select values based on the first # of characters but this is not exactly my question. I need to select RANGE OF values that start with few characters, here is an example of what I want:
if I have the following cases:
I22A33
I22B33
I22C33
I22D33
So I want to select I22B33 and I22C33 out of the above 4 values, so it's like a range of cases between b and c.
One way to flag any cases that meet your criteria is using INDEX and a series of OR conditions. Not particularly modular, but if you just have a couple of conditions you're searching for it could get you on your way.
Edit: These searches are case-insensitive (due to UPCASE) and search for matches at the start of the string. To search for matches anywhere within the string set the condition to > 0 (instead of = 1).
COMPUTE f_I22 = (INDEX(UPCASE(var_name),'I22B33') = 1)
OR (INDEX(UPCASE(var_name),'I22C33') = 1) .
EXE .
Assuming in this range of values that you want to select, all the values will start with either "I22B" or "I22C", you can simply use:
select cases if char.substr(variable_name,1,4)="I22B" or
char.substr(variable_name,1,4)="I22C".
I really need your help with this.
I have created an invoice template in Google Docs with databases flowed from Google sheets.
The problem is:
In the template (Google Docs), I only put a specific items line (eg 3 lines).
When the data is changed, such as the number of items lines are changing, how it's automatically gone through Google Docs if there are more than 3 items lines
Many thanks for your help.
Below is my script to get data from G-sheets to G-Docs template.
function Invoice() {
let copyFile = DriveApp.getFileById('id URL').makeCopy(),
copyID = copyFile.getId(),
copyDoc = DocumentApp.openById(copyID),
copyBody = copyDoc.getBody()
let activeSheet = SpreadsheetApp.getActiveSheet(),
numOfCol = activeSheet.getLastColumn(),
activeRowIndex = activeSheet.getActiveRange().getRowIndex(),
activeRow = activeSheet.getRange(activeRowIndex, 1, 1, numOfCol).getValues(),
headerRow = activeSheet.getRange(1, 1, 1, numOfCol).getValues(),
columnIndex = 0
for (; columnIndex < headerRow[0].length; columnIndex++){
copyBody.replaceText('%' + headerRow[0][columnIndex] + '%', activeRow[0][columnIndex])
}
copyDoc.saveAndClose()
Here is screenshot of the files.
Data in G-sheet with the additional item (Item 4)
G-Docs template with specific 3 rows for 3 items lines
When I have 4 items, I must manually amend the G-Docs template. Is there any way to get its automatically.
#Duc I don't think it's possible to pass the new header as placeholder in the GDoc, it sounds like an endless loop.
Unless you pass it as List_ITEM, but I am pretty sure you will lose formatting.
Example Sheet I'm trying to get an exact match with an array in the criteria section of dget. Maybe there is another way to work around this, but I'm trying to give it a dynamic component in the array.
=dget('Micro Data'!$A$1:J,"PCR Score",{"Micro Type","Stage Type","Tank","ID#";"PCR PAL","Bright",F2,H2})
Sometimes all criteria matches multiple data points except the "Tank". However the tanks won't exactly match. Ex. All the data is the same in two data sets, except the tanks are CT1 and CT18. This then comes up with the #NUM! error. I'm trying to find if there is a way to get an exact match in the array data while still allowing it to reference the cell?
I know there is the option of making it "=XXX" making it a txt string, but this would take away the dynamic function. I would also loose the auto updating aspect when more data is added.
Thanks
Ryan, see my solution using a query, in Retain Log-GK, cell F2. I think it is just as dynamic as the dget, but perhaps not. It will need some error wrapping to avoid errors if no result found.
Formula is basically:
=query('Criteria Source'!A2:J5,
"select J where B = '"&D9&"' and C = '"&D10&"' and E = '"&D11&"' and D ='"& D2 & "' ",0)
I made all of the criteria dynamic, though obviously you can do it whatever way suits you best...
Let me know of any questions. I'll check back later...
new as heck here and I trying to find the best way to further optimize a set of sheets functions.
The starting function was essentially 26 stacked filter functions being used to reference individual cells beneath containing names(strings), find the IDs associated with the names in these cells, pull the IDs from the "ref" sheet, and create a url that contains these IDs. The function, stripped of confidential data:
=HYPERLINK(CONCATENATE("https://url.com/stuff?ids=",if(isna(filter(ref!$B:$B,ref!$A:$A=B3))=true,"",filter(ref!$B:$B,ref!$A:$A=B3)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B4))=true,"",filter(ref!$B:$B,ref!$A:$A=B4)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B5))=true,"",filter(ref!$B:$B,ref!$A:$A=B5)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B6))=true,"",filter(ref!$B:$B,ref!$A:$A=B6)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B7))=true,"",filter(ref!$B:$B,ref!$A:$A=B7)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B8))=true,"",filter(ref!$B:$B,ref!$A:$A=B8)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B9))=true,"",filter(ref!$B:$B,ref!$A:$A=B9)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B10))=true,"",filter(ref!$B:$B,ref!$A:$A=B10)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B11))=true,"",filter(ref!$B:$B,ref!$A:$A=B11)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B12))=true,"",filter(ref!$B:$B,ref!$A:$A=B12)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B13))=true,"",filter(ref!$B:$B,ref!$A:$A=B13)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B14))=true,"",filter(ref!$B:$B,ref!$A:$A=B14)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B15))=true,"",filter(ref!$B:$B,ref!$A:$A=B15)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B16))=true,"",filter(ref!$B:$B,ref!$A:$A=B16)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B17))=true,"",filter(ref!$B:$B,ref!$A:$A=B17)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B18))=true,"",filter(ref!$B:$B,ref!$A:$A=B18)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B19))=true,"",filter(ref!$B:$B,ref!$A:$A=B19)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B20))=true,"",filter(ref!$B:$B,ref!$A:$A=B20)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B21))=true,"",filter(ref!$B:$B,ref!$A:$A=B21)),",",if(isna(filter(ref!$B:$B,ref!$A:$A=B22))=true,"",filter(ref!$B:$B,ref!$A:$A=B22)),"&morestuff=true"),"Group A")
The best I could do to optimize this was to compile the IDs in one cell (B1) with this QUERY function within a TEXTJOIN:
=TEXTJOIN(",",TRUE, QUERY(ref!$A$2:$B, "select B where A = '"&B3&"' or A = '"&B4&"' or A = '"&B5&"' or A = '"&B6&"' or A = '"&B7&"' or A = '"&B8&"' or A = '"&B9&"' or A = '"&B10&"' or A = '"&B11&"' or A = '"&B12&"' or A = '"&B13&"' or A = '"&B14&"' or A = '"&B15&"' or A = '"&B16&"' or A = '"&B17&"' or A = '"&B18&"' or A = '"&B19&"' or A = '"&B20&"' or A = '"&B21&"' or A = '"&B22&"' or A = '"&B23&"' or A = '"&B24&"' or A = '"&B25&"' or A = '"&B26&"' or A = '"&B27&"' or A = '"&B28&"' or A = '"&B29&"' "))
Then do the url generation in another cell (B2), referencing B1 for the IDs:
=HYPERLINK(CONCATENATE("https://url.com/stuff?ids=", ",", B1, "&morestuff=true"), "Group A")
I then copied these across Groups B-Z
I tried multiple variations of FILTER stacked in ARRAYFORMULA but I couldn't get it to work. I'm unsure if there is a syntax I should be using to better handle matching text that I am not quite figuring out. Simply matching by first letter is not an option as there are names that do not qualify for the groupings contained within the "ref" sheet for use in other data sets.
So my question here is really: is there an easier way to compile this where I don't have to reference each cell individually for matches on the "ref" sheet?
For an example of the sheet I am working with, this link should work:
https://docs.google.com/spreadsheets/d/1ykSldWyQnPcar9G21ljLOzm3dWC1i82kMaQJuSKHajc/edit?usp=sharing
Just use another textjoin to construct your query string as follows:
="select B"&if(counta(B3:B)=0,""," where A='")&textjoin("' or A='",true,B3:B)
Not only is this much shorter than manually typing each cell but it will also expand infinitely downward as required.