Google Sheet > Translate String to Function Path - google-sheets

I am creating a summary sheet in which you can select a column title, and below you will get the Sum of this row.
I have a data validation picker that provides you the options, e.g. column "First Col", "Second Col", "Third Col".
Then I translate it using a switch to "A", "B", "C" (actual columns on the other sheet), and even add the full location, e.g. "OtherSheerB2:B10000".
The problem is how can I try to translate the String representing the column as the function path:
In this example, if you chose "Second Col", I will try =Sum("OtherSheerB2:B10000")
and fail :(
Is the idea I am trying even possible? or are there any other suggestion?

Ok so I think I found a solution using SQL e.g.:
=QUERY({OtherSheerB2!$A$2:$T$1000},CONCAT(CONCAT("select sum(Col",M1),")"))
When M1 contains the number of the columns I want to sum.

Related

Making data appear from a dropdown list in Google Sheets

I'm trying to create a sheet that allows me to compare four different properties I'm considering taking a mortgage out on. It contains ranges where I input data (property value, deposit percentage etc) for each of the four properties, and then this feeds into four property displays below which shows me my monthly outgoings for each property.
I'm looking for a way to only see one data input range at a time, using a dropdown to access it. So I could select "Property 1" from the dropdown, it would bring up my Property 1 data input range, I could add the relevant information, and then select Property 2 and do the same etc.
I've tried creating each input range as a named range, and then using =IF to call them like this:
=IF(C8="Property 1",Property_one)
But this just brings up #VALUE! and the error "An array value could not be found."
Any help would be appreciated! Here's a copy of the sheet I've been working on – you can see where I've been faffing around with the =IF function at the bottom.
Thanks in advance!
try:
=INDEX(IF(C8="Property 1", Property_one, ))
or:
=INDEX(IF(C8="Property 1", Property_one,
IF(C8="Property 2", Property_two,
IF(C8="Property 3", Property_three,
IF(C8="Property 4", Property_four, )))))

How can I search for data in Google Sheets using multiple keywords?

I am trying to make a search box in google sheets which searches data based on keywords. This is specific to a spare parts inventory system. Each item is defined by 5 columns namely Type, Part Name, Part Number, Price, Stock.
One example of an item would be "Lockstitch","Needle Bar Bush","229-10312 / 331-2312", "500", "3000".
In a separate sheet, I am trying to make a search box where I put in keywords like "Lockstich" "Bush" and the result should display.
I have tried concatenating the column name into one string and concatenating the keywords and matching them using QUERY function, but the problem that arises is that when I try to search "lockstitch bush" it doesn't give result because it does not contain in the string "Lockstitch Needle Bar Bush 229-10312 / 331-2312 500 3000"
I want the code to separately search each keyword in the combined string and give out results matching the keywords
you can try like this:
=FILTER(A2:E6, REGEXMATCH(TRANSPOSE(QUERY(TRANSPOSE(LOWER(A2:E6)),,999^99)),
TEXTJOIN("|", 1, SPLIT(LOWER(H1), " "))))
or more strict:
=ARRAYFORMULA(QUERY({A2:E6, TRANSPOSE(QUERY(TRANSPOSE(A2:E6),,999^99))},
"select Col1,Col2,Col3,Col4,Col5
where "&TEXTJOIN(" and ", 1, IF(TRANSPOSE(SPLIT(H1, " "))<>"",
"lower(Col6) contains '"&TRANSPOSE(SPLIT(LOWER(H1), " "))&"'", ))&"", 0))

Error parsing query from another page using current page data

I'm attempting to use data on another page (scholar progress reports) to match columns in a current page (copy of results).
Using the formula below:
=QUERY('Copy of Results'!$A$2:$I$999, "select D where A="&'Scholar Progress Reports'!A158&"")
Is producing the following error:
"Unable to parse query string for Function QUERY parameter 2: NO_COLUMN: test"
where 'test' is the value of the cell I'm trying to match on the current page.
Assuming 'test' is in cell A158 of the same sheet, the query is used, try:
=QUERY('Copy of Results'!$A$2:$I$999, "select D where A='"&A158&"'", 0)
Else, try
=QUERY('Copy of Results'!$A$2:$I$999, "select D where A='"&'Scholar Progress Reports'!A158&"'", 0)
My immediate thought is exactly what the error says "NO_COLUMN: test". In your formula, are you trying to select a column, or something like that, called "test" instead of using the names "A", "B", etc.?
If that's not it, do you have a sample sheet?
THIS may also help.

How to maintain the original header name when performing Google Sheets Query

Hi I have this working query that loops through an arbitrary range of data and produces the results I need:
=arrayformula(QUERY(Crew!A:DY,"SELECT E,A," & join(",", substitute("Count(`1`)", "1",substitute(address(1, column(Crew!F:DY), 4), "1", ""))) & "GROUP BY E,A", 1))
Unfortunately, this produces Columns that are labeled so:
count 18/12/2017 count 25/12/2017 count 01/01/2018
I need to force a display of the original column name, and if possible, the format, e.g. 18/12/2017 as this will allow me to perform further pivot or group by month type functions
I have experimented with different methods of adding a label at the end of the query, reduced the query to tests of the data without using the arrayformula, and searched through the queryLanguage Docs but all references seem to be related to applying a different text string rather than leaving the column header 'raw'
I suspect the main problem is my inexperience, I don't know the correct terms to search for?
How do I achieve this?
Cheers.
You need to use label construction:
"select ... where ... group by ... label ..."
Reference:
https://developers.google.com/chart/interactive/docs/querylanguage#label
You may get labels text with the formula:
="label "&ArrayFormula(join(", ",substitute("count(`1`) ", "1",substitute(address(1, column(F1:G1), 4), "1", ""))&text(F1:G1," 'dd/mm/yyy'")))
change F1:G1 to your range.
The shorter version of the formula with Regex:
="label "&ArrayFormula(join(", ",REGEXREPLACE(ADDRESS(1,COLUMN(F1:G1),4),"(.*)\d+$","count(`$1`) "&TEXT(F1:G1,"'dd/mm/yyy'"))))

Google Sheets: "Bob Smith" --> "bsmith" formula?

I'm trying to pull data from another Google Sheet to feed another Google Sheet. I need to pull from a full name field, which will have something like, "Bob Smith" and then I need to have it rewrite into the new Google Sheet as "bsmith".
Basically, "Get first letter of the first string, then concatenate the entire second string, and then make all lowercase."
So far I've gotten =LEFT(A28,1) working to grab the first letter of a string, but then not sure how to grab the second word and then concatenate.
To get the 2nd word you need to FIND() the first space then read from that position + 1 to the end of the string using MID(). & is used for concatenation.
=lower(left(A28,1) & mid(A28, find(" ", A28) + 1, len(A28)))
Try this for a Google sheet specific solution:
=LOWER(REGEXREPLACE(A2,"^(\w).*?(\w+$)","$1$2"))
It uses REGEX, a much more sophisticated engine and easily adaptable to variations than LEFT and/or MID.
Shorter:
=lower(left(A28)&index(split(A28," "),2))
(Assumes only ever two words.)

Resources