Hello Help Community,
I am trying to find a way to alternate queries from drop down menus. The idea is to be able to move between a list of queries and not have to rewrite the query when I want to use it again. I saw this done by writing the select statement in a drop down and referencing the cell containing the select statement in the query like this:
=QUERY(range, "" """"""&cell&"""""" "")
However, I cannot get this method to work. I can manipulate the same query using cell references and drop down menus but I would like to do more if it is possible.
Any idea how this could be achieved would be appreciated.
Regards, Andrew H"
example:
=QUERY(A2:D5, "where A = '"&B8&"'", 1)
if dropdown contains numbers use:
=QUERY(A2:D5, "where A = "&B8, 1)
Related
Let’s say I have a list of URLs like this:
https://moz.com/
https://moz.com/about
https://moz.com/about/contact
https://moz.com/about/jobs
https://moz.com/beginners-guide-to-seo
https://moz.com/blog
https://moz.com/blog/category/advanced-seo
https://moz.com/blog/advanced-seo/technical
https://moz.com/blog/advanced-seo/content
https://moz.com/blog/googles-walled-garden
https://moz.com/blog/local-search-ranking-factors-survey-results-2017
https://moz.com/explorer
https://moz.com/help
https://moz.com/help/guides
https://moz.com/help/guides/moz-pro-overview
And I wanted it to be displayd in different columns according to the depth of the structure. Like each part of the URL is a level in the sites hierarchy and I want to visualize the hierarchy as such:
https://moz.com/
https://moz.com/about
https://moz.com/about/contact
https://moz.com/about/jobs
https://moz.com/beginners-guide-to-seo
https://moz.com/blog
https://moz.com/blog/advanced-seo
https://moz.com/blog/advanced-seo/technical
https://moz.com/blog/advanced-seo/content
https://moz.com/blog/googles-walled-garden
https://moz.com/blog/local-search-ranking-factors-survey-results-2017
https://moz.com/explorer
https://moz.com/help
https://moz.com/help/guides
https://moz.com/help/guides/moz-pro-overview
How can I do this? I have already tried utilizing the split function for this but that does not work because it just splits the different parts of the URL into different columns and not the whole URL into the accordant column.
Thanks in advance :)
Suppose the range with links is A:A:
Put the formula =ArrayFormula(COUNTIF(REGEXMATCH(A2,$A$1:A1), true))*1 in B2 and drag it down
Put the formula =REPT(" ",B1)&A1 in C1 and drag it down.
Edit1
Here's the single formula to do the same:
=ARRAYFORMULA(rept(" ",MMULT(
--(REGEXMATCH(A1:A15,TRANSPOSE(OFFSET(A1:A15,1,)))),SIGN(A1:A15<>""))-1)&A1:A15)
Edit2
this is a brilliant solution thank you alot. However it seems I run
into problems with sites that include .html at the very end
(moz.com/about.html but moz.com/about/contact.html and so on). Any
ideas how to bypass that?
=ARRAYFORMULA(rept(" ",MMULT(--(REGEXMATCH(A1:A15,REGEXREPLACE(TRANSPOSE(OFFSET(A1:A15,1,)),"\.html$",""))),
SIGN(A1:A15<>""))-1)&A1:A15)
Notes:
the formula also replaces ".html" from the end of a string.
So I am trying to use a simple QUERY function in Google Sheets where I want to select based on TWO parameters. Simple logic, and documentation says use the AND operator. The problem is I am searching for text via Cell Reference.
So here is my function
=QUERY(A1:D6,"select A where C='" &K1&'"" & "and D='" &K2"'")
Unfortunately it throws up an ERROR. I understand that Cell References that are text based need to be in single quotes (which themselves need to be in double quotes), but I am unable to join two WHERE statements.
What is the right syntax for this?
Very close indeed, please try:
=query(A1:D6,"select A where C='"&K1&"' and D='"&K2&"' ")
Welp! I was missing an concatenation symbol (&) at the end of the final cell reference K2.
=QUERY(A1:D6,"select A where C='" &K1&'"" & "and D='" &K2&"'")
I want to create a TFS query to show all the Work Items of type "Issue" & "Requirement" created by person "A" & "B".
I have the below query but it doesn't give me the expected results:
Can someone please tell me what changes I need to make?
Change the Created By clauses to "Or" and grouping them together. That should give you your expected results. Like this:
Found the answer here
https://msdn.microsoft.com/en-us/library/ms181360(v=vs.90).aspx
Thank you !
Adding details as suggested in the comments by #ios82
The main thing I had to do was to use the "grouped clauses" as described in the link above.
You do that by selecting the parameters you want to group by, right clicking and selecting the option of "Group Clauses". Screenshot below.
In my case I grouped both the "work item type" clauses together & the "created by". clauses together.
Also, the Condition on the CreatedBy (B) Should be changed to "OR" instead of "AND". That did it !!
I have table with 3 columns : tableno,itmname, itmtype. The itmtype can be red or blue only. This table may have rows like: table01,item1,red ; table01,item2,blue; table02,item1,blue; table02,item4,red; table03,item1,red; table03,item5,red.
Now I need to extract tableno for which all itmtypes is red. So from above rows I need output as table03 as itmtype is red for both items in it. Normally if I put where condition for itmtype as red, it may fetch table01 & table02 as well coz both has one item with itmtype red. But I need only table03 as my output coz all itmtype is red for this table.
I am struggling for quite long time writing different types of queries in rails but none of them is working.
I have written a sql query for that unable to write a similar one in rails.
select tableno,itmstatus,count(itmstatus) from lists l1 group by l1.tableno,itmstatus
having itmstatus = 'red' and count(itmstatus) = (select count(itmstatus) from lists l2 where l1.tableno = l2.tableno group by tableno)
Since I am unable to convert this in rails, couldn't test on rails console to check if it will work. I understand that this may sound a basic question but being new to rails I have only used normal select only. Please advise. Thanks.
if you have correct sql syntax then put it in a string and use the find_by_sql method
like
Model.find_by_sql("your query")
please check the links
http://apidock.com/rails/ActiveRecord/Base/find_by_sql/class
find_by_sql with array format in Rails 3
Symptoms:
Searching for a single word (i.e. "Snap") works
Searching for another word contained in the same field (i.e. "On") also works
Searching for "Snap On" at the same time returns 0 results, even though it shouldn't.
The setup:
SQL Server 2008 R2 with Advanced Features
nopCommerce 3.0
Things I have done:
I added the Product.MetaKeywords column to the full text search catalog
I added a bit into the Stored Procedure that performs the search to search through the MetaKeywords
Now the nopCommerce boards are fairly slow, but I'm positive the problem is within the SQL Stored Procedure anyway, so I figured I would ask for some SQL Server help here, even if you aren't familiar with the nopCommerce web app, you may have some information you can help me with.
The stored procedure in question is too large to post entirely here, but basically it dynamically adds "OR" or "AND" in between the keyword searches to generate the phrase used in a Contains clause. It selects through several unions various searchable fields by using Contains.
Here is the bit I added into the stored procedure
SET #sql = #sql + '
UNION
SELECT p.Id
FROM Product p with (NOLOCK)
WHERE '
IF #UseFullTextSearch = 1
SET #sql = #sql + 'CONTAINS(p.[MetaKeywords], #Keywords) '
ELSE
SET #sql = #sql + 'PATINDEX(#Keywords, p.[MetaKeywords]) > 0 '
#Keywords, at this point, if I am reading the procedure correctly, has a value of: "Snap* AND On*"
I don't understand why my query of "Snap On" returns 0 results, but "Snap" and "On" individually work fine.
The minimum search length is set to 1, so it's not that.
I should add that searching for "Snap* OR On*" works, but I cannot use OR because then searching for "Snap On" will also return "Snap Dragon" and other unrelated things.
--EDIT--
The problem wasn't any of that. I got some advice elsewhere and the problem was actually the stoplist. I managed to fix my issue simply by changing the stoplist on the product table from <system> to <off>.
To do this, follow these steps.
browse to your table in SQL Server management studio
Right click on the table and select "Full-Text Index"
Select "Properties" under "Full-Text Index"
In the "General" Tab, change "Full-Text Index Stoplist" to <off>
I had to do it this way because I was unable to get the transact SQL to work. It kept telling me there was no such object as the table I was attempting to modify. If anyone can provide any insight on how the Alter fulltext index statement works, I'm interested, because I was following the example on the MSDN page to the T and it just kept telling me there was no such object named Product.
The asterisk is not a plain old wildcard. If you are using it anywhere other than at the end of a search term, you're probably not using it correctly. See answers to a similar question
SQL Contains Question
In your case, each search term must be quoted separately. See this example from the docs http://technet.microsoft.com/en-us/library/ms187787(v=sql.90).aspx
SELECT Name
FROM Production.Product
WHERE CONTAINS(Name, '"chain*" OR "full*"');