Using querybuilder.js example (https://querybuilder.js.org/) I do not see a way to have both AND and OR statement. For example, If I wanted to build a query that includes:
(Name = "Name 1" AND Name = "Name 2") OR (Price = 1.00)
I don't see a way to add this. I can make it all "AND" or all "OR". If I add the first two AND fields, then add a single GROUP, I still cannot denote that GROUP as "OR", as the AND/OR button for that group is disabled. Is there a way to override this functionality? OR, is there another way to hand this case?
Please find the setup below for your answer. This case is very basic and should be supported by any query buider.
Related
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)
I was wondering if there was a syntax to select all account names that include a certain string of text.
For example, if I have a SPSS file that has 3 million account names, I'd want to look at only the account names that have a / TKS at the end. The account name could like like Stack Overflow / TKS.
You can use char.index to check whether a string includes a specific substring.
So for example:
compute containsTKS=0.
if char.index(account_name,"/ TKS")>0 containsTKS=1.
execute.
You can then use containsTKS to filter or select cases.
The solution eli-k provided checks if / TKS is inside the account_name, at any position.
If you want to check if the "/ TKS" text is at the end of your account_name, you need a slightly changed syntax:
compute containsTKS=0.
if char.index(account_name,"/ TKS")=char.len(rtrim(account_name))-5 containsTKS=1.
execute.
Then, as eli-k mentioned, "You can then use containsTKS to filter or select cases."
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 !!
Shown below is the bottom half of the query I'm working on. The query returns all the values I want, but CSV is breaking apart account names that include commas (e.g. Sales, General and admin) into multiple columns.
I started looking at VBA code a few weeks ago and despite finding numerous pages on the replace function, I couldn't figure out how to get it to run inside my code, specifically after the query and before the delimiter so that the account names are kept intact/separate from the data.
Account names are changed fairly frequently, so ultimately I need a code that allows me to either enter specific account names that include commas so the code knows to ignore those commas, or a parse type function. Thanks in advance.
QueryQuote:
With Sheets("Income").QueryTables.Add(Connection:="URL;" & qurl, Destination:=Sheets("Income").Range("a1"))
.BackgroundQuery = True
.TablesOnlyFromHTML = False
.Refresh BackgroundQuery:=False
.SaveData = True
End With
Sheets("Income").Range("a1").CurrentRegion.TextToColumns Destination:=Sheets("Income").Range("a1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=True, Space:=False, other:=False
Sheets("Income").Columns("A").ColumnWidth = 20
Sheets("Income").Columns("B:L").ColumnWidth = 8
End Sub
Find and Replace:
Cells.Replace What:="insert text here", Replacement:"insert replacement text here", _
LookAt:=xlPart, SearchOrder:=xlByRows, _
MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
This is the vBA for the Find and Replace function. Use this for each phrase that needs to be found and replaced.
This is a Text To Columns formula:
Sheets("Income").Range("a1").CurrentRegion.TextToColumns _ Destination:=Sheets"Income").Range("a1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _
Comma:=True, Space:=False, other:=False
The Comma:=True is what is separating your data. Try changing that to false.
I have a list of keywords that I need to search against, using ThinkingSphinx
Some of them being more important than others, i need to find a way to weight those words.
So far, the only solution i came up with is to repeat x number of times the same word in my query to increase its relevance.
Eg:
3 keywords, each of them having a level of importance: Blue(1) Recent(2) Fun(3)
I run this query
MyModel.search "Blue Recent Recent Fun Fun Fun", :match_mode => :any
Not very elegant, and quite limiting.
Does anyone have a better idea?
If you can get those keywords into a separate field, then you could weight those fields to be more important. That's about the only good approach I can think of, though.
MyModel.search "Blue Recent Fun", :field_weights => {"keywords" => 100}
Recently I've been using Sphinx extensively, and since the death of UltraSphinx, I started using Pat's great plugin (Thanks Pat, I'll buy you a coffee in Melbourne soon!)
I see a possible solution based on your original idea, but you need to make changes to the data at "index time" not "run time".
Try this:
Modify your Sphinx SQL query to replace "Blue" with "Blue Blue Blue Blue", "Recent" with "Recent Recent Recent" and "Fun" with "Fun Fun". This will magnify any occurrences of your special keywords.
e.g. SELECT REPLACE(my_text_col,"blue","blue blue blue") as my_text_col ...
You probably want to do them all at once, so just nest the replace calls.
e.g. SELECT REPLACE(REPLACE(my_text_col,"fun","fun fun"),"blue","blue blue blue") as my_text_col ...
Next, change your ranking mode to SPH_RANK_WORDCOUNT. This way maximum relevancy is given to the frequency of the keywords.
(Optional) Imagine you have a list of keywords related to your special keywords. For example "pale blue" relates to "blue" and "pleasant" relates to "fun". At run time, rewrite the query text to look for the target word instead. You can store these words easily in a hash, and then loop through it to make the replacements.
# Add trigger words as the key,
# and the related special keyword as the value
trigger_words = {}
trigger_words['pale blue'] = 'blue'
trigger_words['pleasant'] = 'fun'
# Now loop through each query term and see if it should be replaced
new_query = ""
query.split.each do |word|
word = trigger_words[word] if trigger_words.has_key?(word)
new_query = new_query + ' ' word
end
Now you have quasi-keyword-clustering too. Sphinx is really a fantastic technology, enjoy!