Query Data between to strings - google-sheets

So I am importing data from an external program, the problem is it imports the data not separated, so when I import and trans pose it, it ends up like this:
Column A
String#1
Data 1
Data 2
Data 3
String#2
Data 4
Data 5
Data 6
I want to query the Data above so it grabs "string 1" and goes down until it gets to "String2", so I an rearrange the data to look like this:
String 1
String 2
Data 1
Data 5
Data 2
Data 6
Data 3
Data 7
Data 4
Data 8
I have absolutely no idea how todo this, my assumption is that the formula would look like this:
=QUERY(A:A, "Select A where A is between 'String 1' and 'String 2')
And no, I cannot change the way the data is imported from the external tool.
Any ideas and solutions would be very apricated

Related

sync data between to tabs/sheets columns with the same columns in each

Hello Trying to write a simple formula to have two people enter the same data in each of their tabs in the same google sheet--workbook ( no script)
I created the identical row on both tabs. Colum R 1-196 only using R9—196 for data It would be the same data. With all cells using plain text numbers from
2022-000000 and 0000 So if person 1 enters the data or person 2
Both tabs/sheet colums will get populated with the data. I just don't know how to write it and where to write it.
=DailyAlarmsReport_Online sheet/tab 1
=May_LiveTracking shhet/tab 2
=’DailyAlarmsReport_Online’!R9:R196. To =’May_LiveTracking’!R9:R196
And =’May_LiveTracking’!R9:R196 to =’DailyAlarmsReport_Online’!R9:R196
enter image description here enter image description here
you will need a 3rd tab that would compile data from those 2 sheets. formula would be for example:
=ARRAYFORMULA(IF('DailyAlarmsReport_Online'!R9:R196=""; 'May_LiveTracking'!R9:R196; 'DailyAlarmsReport_Online'!R9:R196))

Determine the DateTime encoding or format

I'm writing a Delphi program that needs to interact with data stored in a SQLite database that belongs to another program. Everything ok so far, except that I'm unable to get the date/time value from the data store in a column in the SQLite database, with the data type 'datetime'.
I do know that the data type of fields is not relevant in SQLite, and that everything is stored as strings, and perhaps that is possibly the reason why I find myself in this predicament.
Below is a sample of a few rows of the data stored in the SQLite database (column 3) vs. the corresponding date value displayed in the program (column 2) that reads and writes to this SQLite database:
1 11/7/1971 621939168000000000
2 3/17/1976 623314656000000000
3 5/4/1996 629667648000000000
4 9/21/2007 633259296000000000
5 11/17/1972 622264032000000000
6 2/7/1996 629592480000000000
7 6/13/2000 630964512000000000
My requirement: Once I read the value in column 3 from my Delphi program, how do I translate it to the same date/time value as displayed in column 2? I have tried the UnixToDateTime function, but it does not result in the same value (as column 2). Can anyone help?
Thanks in advance!
The value in column 3 is the number of 100 nanoseconds since 1/1/0001. You can convert it into a Delphi TDateTime like this:
theDate := (Value/864000000000) - 693593;

How can I reformat a "matrix report" in Google Sheets into a clean data sheet?

Sorry for the imprecise title, I'm not sure what this format is called. I received a "research database" in format you see below and need to convert it (and dozens more like it) into a useable format.
The sheets look like this:
COMPANY
Report 1
Report 2
Report 3
Report 4
Company 1
46.8
-0.2
0.2
Company 2
45.7
-0.3
I need to convert it to a properly formatted data sheet so I can upload it to a database. In other words, it needs to become:
Company
Report
Score
Company 1
Report 1
46.8
Company 1
Report 2
-0.2
Company 1
Report 3
Company 2
Report 4
0.2
Company 2
Report 1
45.7
Company 2
Report 3
-0.3
Company 2
Report 4
It's ok if we end up with rows with no value, those are easy enough to purge.
Sample sheet here
First, you'll want to delete what appears to be test data from A9:C of your "Data as Is" sheet.
After that, delete everything you currently have in the results sheet (or create a new blank one) and place the following formula in A1:
=ArrayFormula({"Company","Report","Score";SPLIT(QUERY(FLATTEN(IF('Data as Is'!B2:E="",,'Data as Is'!A2:A&"~"&'Data as Is'!B1:E1&"~"&'Data as Is'!B2:E)),"Select * WHERE Col1 Is Not Null"),"~")})
This will produce your headers and all results, with no-result rows already removed.
From there, you can format headers and data as you like.
Try this, where tab is your data
=query({
arrayformula(vlookup((roundup(flatten(sequence(columns(tab),rows(tab),1,1)/columns(tab)))),{flatten(sequence(columns(tab),rows(tab),1,1)),flatten(transpose(tab))},2,0)),
arrayformula(vlookup(mod(flatten(sequence(rows(tab),columns(tab),0,1)),columns(tab))+1,{flatten(sequence(rows(tab),columns(tab),1,1)),flatten(tab)},2,0)),
flatten(tab)
},"select * where Col1 is not null and Col2 is not null and Col3 is not null",0)

Google Sheets Query Drop Down Filtered Returned Values Not Resetting

Using the following code, I've been able to query a single column properly from my dataset where B2 and B3 are drop downs that I use to filter and D1 is just a header (I have multiple queries side by side that use the same filters)
=IFERROR(QUERY('Input Sheet'!$A:$E, "select A where B = '"&$B$2&"' and C = '"&D$1&"' and D ='"&$B$3&"'",0),"")
I've tried looking it up and when I see other people use the Query function, their search area will reset upon changing their drop down filters. What I mean is, if the first query returns 4 rows and the second returns 1, only my first row will update for the query.
Updated to include sample data and video. Sorry I can't post directly into thread.
Dataset (date is excluded since it isn't relevant to my query)
Dropdowns
Query Table and Filters
Video
So if my first query has 4 rows and my next query returns only 1 row, the last 3 rows will not update.
So for example, lets say my first query returns the following:
10
19
32
41
Changing a filter will return
23
19
32
41
But in reality, the query should only return 23, the rest of the values are from the previous query. None of the videos I've watched have this problem (so none have addressed my issue)
If I change my filters to something that should return nothing (no data entries) I get the following:
"" (Empty Cell, Null etc)
19
32
41
My data source is formatted like the below
A B C D
1 2 3 4
w x y z
Any help would be appreciated. Thanks.

Google Sheets - comparing dates and returning the latest row with requirements

I have a sheet that uses a query to pull data from another sheet. This data, looks a bit like this.
DATE STOREID OTHERDATA
02/11/2017 Store 1 Other data 1
01/11/2017 Store 1 Other data 2
09/10/2017 Store 2 Other data 3
05/10/2017 Store 2 Other data 4
I'm looking for a way for it to return only the latest date row per store, as seen below.
DATE STOREID OTHERDATA
02/11/2017 Store 1 Other data 1
09/10/2017 Store 2 Other data 3
The query I'm currently using looks something like this:
=query(DATASHEET!A2:CF11, "select C, CC, L,CD, E, BZ, CA, CB where (BF='CUSTOMERNAME1') order by C desc, CC, L, BZ desc",0)
Is this possible to make the query look at all dates and storeIDs and only return the highest date per storeID? I can imagine doing this in another language with a loop/for, but my Google results tell me it's not possible with query.
If that is the case, how would you recommend I do this in the data sheet so I could have a column say either LATEST / NOT LATEST for each row and then use query with a WHERE statement?
Here's an example sheet I tried setting up in case it helps explain what I'm trying to do.
https://docs.google.com/spreadsheets/removed
Any help is appreciated as I've spent all day trying to figure it out. Let me know if anything is unclear.
Thanks!!
Try this one:
=ARRAYFORMULA(VLOOKUP(QUERY({ROW(A2:A),SORT(A2:C)}, "SELECT MAX(Col1) WHERE Col3 IS NOT NULL GROUP BY Col3 LABEL MAX(Col1)''",0),{ROW(A2:A), SORT(A2:C)},{2,3,4},0))
Try this:
=ARRAYFORMULA(VLOOKUP(UNIQUE(B1:B11),SORT({B1:C11,A1:A11},3,0),{3,1,2},0))
By Reverse SORTing by Column A, and VLOOKUPing UNIQUE values, We have the latest row.

Resources