Query CONTAINS not working only selecting where equals - google-sheets-query

Queries using contains have recently stopped working correctly.
When value in source data column is 1,2,3 and the query is WHERE B contains '3'
See test sheet here:
https://docs.google.com/spreadsheets/d/1tCJBerHOmVfKbtb81JEyWEp6ZYP0EXyJqG-_7zVWpLw/edit?usp=sharing
Update
It appears that google is now first applying the Number Formatting to the cell then running the QUERY. Ensure your data column is set to PLAIN TEXT.

In your example, add say z (any text) into B7 and John should appear in the output of your query.

As per the Update Google has changed to now first run the "Number Format" filters, then the QUERY method runs on the field.
So by default AUTOMATIC NUMBER formatting is applied - google based on the value sets the format on what it thinks is correct.
FIX: Set data to FORMAT > NUMBER > PLAIN TEXT
I have updated the example to illustrate this.
This change would probably assist the general Google Sheets user, but where you are working off raw data ensure you set the PLAIN TEXT number format on the columns.

Related

What ID does a ComboBox reference?

I am attempting to maintain and fix a horribly out-of-date CRM designed by an ex-employee ~4-5 years ago in Access 2007. I have brought it into Access 2013 and fixed a ton of stuff up, but I am still running into many problems.
I spent a good 4 hours today attempting to figure out why certain values didn't line up. These values were being pulled from a SELECT statement on a Combo Box over a stored Query which simply returns a table with a few extra rows. Great.
However this value (a number) doesn't appear to correlate with what we expect. I enter in one value, save the ticket, and a completely different value gets stored into the table. Opening up the ticket, I see the value that I expect. Digging deeper, I found the following difference:
Set value_1 = Me.RegistrationID // What's being stored in the table
Set value_2 = Me.RegistrationID.Column(0) // What we expect
Surprise surprise! This is a Combo Box and some value is being stored in the table. The Control Source is "RegistrationID" and the Row Source is the query in question.
However I do not know what it is! This specific value correlating to the Combo Box appears to pull the correct data when we later open the tickets. However I have a strong feeling that this could be why many tickets from before one of the rows was deleted all appear to have invalid RegistrationID's.
How badly can this break?
How easily can we correct tens of thousands of tickets?
How can I fix this to store the correct value?
This is what I expect is happening.
Your combo box row source is based on a Select query which returns and displays multiple rows. For example:
Select RegistrationID, CustomerID, CustomerName From MyTable;
The Control Source for the combo box is bound to RegistrationID which is part of the Forms Record Source.
The issue is the bound column. If we set the bound column in our example to 1, then we get the behavior your are describing with:
Set value_1 = Me.RegistrationID - Set's value to CustomerID (may appear correct)
Set value_2 = Me.RegistrationID.Column(0) - position 0 from our query (RegistrationID)
Further building on our query example, you can say:
Me.TextBox1 = Me.RegistrationID.Column(0) - RegistrationID
Me.TextBox2 = Me.RegistrationID.Column(1) - CustomerID
Me.TextBox3 = Me.RegistrationID.Column(2) - CustomerName
The RegistrationID is what normally should be stored in the table.
As long as your form shows any values that directly relate to this RegistrationID you're fine.
I would start by checking to see under the format setting to see if column widths are set properly and I would also check under the data section to see if the bound column is correct. I might also throw in an after update macro/vba sub routine that saves the record. Hope this helps.

Find the strings that contain at least one of substrings from a range

I am facing a problem to search a value from a range into a string. Here is my sample of data and expected results
I am working with Google Sheets and I can use custom formula if it's
necessary.
You can do this with regexextract - if you only are searching for example for the "value 1" in the first set of strings in A2 you would use
=REGEXEXTRACT(A2,D2)
If your checking to see if A2 has either B2,B3,B4 then you can use:
=REGEXEXTRACT(A2,JOIN("|",B2:B4))
If a row doesnt have the value your searching for, you can remove the default #N/A by wrapping either function in iferror.
=IFERROR(REGEXEXTRACT(A2,D2))
=IFERROR(REGEXEXTRACT(A2,JOIN("|",B2:B4)))
If your process is slightly different , then please elaborate with a couple more details or share a sample spreadsheet

ms access data type issue when using a linked table to an excel document

I have a spreadsheet which is a report from an external supplier. The date columns are formatted completely different from how a little acccess database works, so i decided to record a macro in excel to alter the 3 columns to a dd/mm/yyyy format (im uk btw). This all works great and the column isshowing as above and is listed as a 'DATE' format also.
Now i use access to link to this excel sheet by means of a linked table, but i noticed that any queries that i wish to filter on those fields in the form of a where clause, it does not pull in the expected result IE it pulls all dates and not the ones between what i asked for in the queryalmost as if it is not recognizing them as dates see the where clause below
WHERE LatestGamma.ConfirmedPortingDate Between [Please Provide 1st Date (dd/mm/yyyy)] And [Please Provide 2nd Date (dd/mm/yyyy)];
I also tested it by using actual dates in the between cluase and it still appears to ignore it.
When i look at the properties of linked table for those columns, it shows that the fields are: dd/mm/yyyy;# but are showing as text??
When i look at the excel macro to see what code the macro used for changing the date format of the columns i see:
Columns("F:H").Select
Selection.NumberFormat = "dd/mm/yyyy;#"
I have another excel sheet that is used as a linked table and date columns are working fine and show as date/time and not Text. Its almost as if excel is putting some meta data into the columns that is making access interprate them as text (even though they are formatted as date)
Im stuck her some help/advise would be great
Its hard to tell without looking at the file, but it seems the main culprit is the excel macro which is not converting the string to date format correctly. You can try converting string into date format by using something like this in excel VBA
Sub convert()
Dim str1 As String
str1 = Range("f6").Value
startdate = CDate(str1)
End Sub
You probably will have to loop thru all the cells to convert the string (text) into date format.
Sorted it in the end. It was more or less what i was thinking IE the column although was showing as a Date type seemed to be storing it as some sort of text. Anyway the way round it was to use the text to columns button and force it to be a date in DMY format.
Once i had tried it i then recorded the actions as a macro and copied the resulting code to my main macro at the end, bingo ! Access now sees it as a date and not text.
Not sure if it is a bug or not but Excel can be a real pain sometimes especially with phone numbers, having to store them as a data type text to keep the leading zero and then immediately converting them to General to allow vlookups etc. I guess that is the same sort of thinkg going on above showing as a date yet actually having like a suedo text meta thing going on...

MySQL TEXT Column - retrieve the length of the row-cell value & also perform trim

I am reading contents of a file and adding it as a row in mysql db. The column in which the file contens will be added is a TEXT column.
There are multiple files that will be uploaded and it's contents are extracted in a cronjob and added to the TEXT column. One row per file.
My files sometimes are empty. In that case, a row with no content is created.
Now, I need to retrieve this content in another cronjob and perform some activities. I would like to filter and retrieve only those rows where content exists. Like using where clause with LENGTH(TRIM(ContentCol)) > 0. Since it is a TEXT column, I am unable to use LENGTH & TRIM functions.
Also when I use LENGTH function, it show different length.. I could see 5, 1 etc. though there is no value in the row-cell.
How can I perform this criteria?
Well I use the function BIT_LENGTH(string); but only with short text data.
This function only return the length of bits, I evaluate this like
BIT_LENGTH(string) > 0

Reporting Services displays #Error if no rows to display.

I'm creating a rather simple report with Reporting Services and noticed that if my data source (which is XML / Web Service) returns no rows, I get #Error text in the text cells that contain some formatting or aggregation logic. It displays one row + the totals row with all datasource cells empty except for the aforementioned calculated ones.
Any idea how I can get rid of these messages?
One thing you can do is set conditional visibility on the details row accessing the "Hidden" property.
=IIF(CountRows("DataSetName") = 0,true,false)
Another thing you can do is check the fields "IsMissing" property before setting it.
=IIF(Fields!Item.IsMissing,"",Fields!Item.Value)
You need to do data validation within each of those cells to make sure something is not blank. It is erroring because it is trying to do a calculation on a blank value. Try:
=IIF(IsNothing(Fields!Item.Value),"",Do Calculations)