Create a series to fill-in data from another sheet - google-sheets

I have a sheet which looks like :
Employee
Sat 10 /01
Sun 10 /02
Mon 10 /03
Tue 10 /04
Wed 10 /05
a
1
1
b
1
1
c
1
1
d
1
1
1
1
e
1
1
1
I have transposed this sheet:
Employee
a
b
c
d
e
Sat 10 /01
1
1
1
Sun 10 /02
1
1
1
Mon 10 /03
1
1
1
Tue 10 /04
1
1
1
Wed 10 /05
1
I just want that each of entries are connected with each other which simply means, using this formula on each cell i.e B2 in sheet 2 should be connected using a formula : =Sheet2!B2 and B3 should be =Sheet2!C2, but dragging down the formula it gives =Sheet2!B3, =Sheet2!B4 and so on, but I want this formula to work horizontally.
I'd appreciate your help because this data is quite large (approximately 90-100 employees).

Use this if you want to transpose sheet1 in sheet2
=TRANSPOSE(Sheet1!A1:500)

Is there anyway I can create a series like =Sheet4!B2, =Sheet4!C2, =Sheet4!D2
try dragging down:
=INDIRECT(ADDRESS(2, ROW(A1), 4,, "Sheet4"))

Related

InfluxDB get list of changes

I would like to get a result such as the following:
name from_value to_value at
tag A 10 15 2019-02-11 16:00
tag B 1 2 2019-02-11 16:00
tag A 15 20 2019-02-11 16:05
tag B 2 3 2019-02-11 16:05
tag A 20 25 2019-02-11 16:10
tag B 3 4 2019-02-11 16:10
basically a column "from_value" (previous value current point) and a column "to_value" (current value current point).
To select only the current point value I do:
SELECT value FROM data WHERE "name"='tag A'
What if I wanted to select also the previous value?
SELECT prev(value) AS "from_value", value AS "to_value" FROM data WHERE "name"='tag A'
Can I do something like the above or I need to always save the previous value every time for every new point?
With group by time you can use last() and difference() functions to get value changes per time interval.
SELECT LAST(value)-DIFFERENCE(LAST(value)) as FromValue, LAST(value) as ToValue
FROM demo where time > 1549983975150000000
GROUP BY time(10ms),tagA FILL(none)
name: demo
tags: tagA=1
time FromValue ToValue
---- --------- -------
1549984410470000000 10
1549984421820000000 10 15
1549984431180000000 15 17
1549984436350000000 17 10
1549984753810000000 10 10
SELECT * FROM demo
name: demo
time tagA value
---- ---- -----
1549984410475859753 1 10
1549984421827992234 1 15
1549984431180379398 1 17
1549984436356232522 1 10
1549984753817094214 1 10

Google sheets query returning incorrect date

I have a got a query where I'm trying to pull in the next 14 days events and previous 14 days events
For some reason, I'm getting very dates added which are in the past or way into the future
=QUERY(Sheet1!A2:H200,"select A,B,G where dateDiff(now(), G) <14 and G is not null")
ABC 1 15 Feb 2019
ABC 1 1 Nov 2018
DFG 1 11 Nov 2018
ABC 1 2 Nov 2018
Next is the previous 14 days
=QUERY(Sheet1!A:G,"select A,B,G where dateDiff(now(), G) >14 and G is not null")
ABC 1 20 Oct 2018
ABC 1 20 Oct 2018
I'm doing something wrong with the query
https://docs.google.com/spreadsheets/d/1WI-FS0XFGi09d2wO005S3kOV_L2s9eR3ILxST6I1nVU/edit?usp=sharing
If you wanted to do it all using datediff, it would be
=query(A:C,"select A,B,C where datediff(C,now())<14 and datediff(C,now())>0")
for dates in next fortnight (fourteen nights or 2 weeks) and
=query(A:C,"select A,B,C where datediff(now(),C)<14 and datediff(now(),C)>0")
for previous fortnight.
You might want to put <= and >=, depending whether you want to include today's date and date 14 days before/after today.
When you use less than 14, Future dates are also included because datediff returns a negative number. So, add a another condition to exclude future dates like:
=QUERY(A:C,"select A,B,C where dateDiff(now(), C) <14 and C<now() and C is not null")

Transpose and repeat column

I know this might be a long shot but here it goes:
Let's assume I have this data:
A B
2014 1
2015 2
2016 3
2017 4
2018
Those columns are not related. But based on that I would like to create a table like this:
2014 2014 2014 2014 2015 2015 2015 2015 2016 2016 2016 2016
1 2 3 4 1 2 3 4 1 2 3 4
Or even better have each column repeated 5 times. What I want to achieve i that I will have data for each year and quarter, and then I would like to display each quarter separately and at the end of each year to have an average:
2014 2014 2014 2014 2014 2015 2015 2015 2015 2015 2016 2016 2016 2016 2016
1 2 3 4 avg 1 2 3 4 avg 1 2 3 4 avg
I've used TRANSPOSE(A2:B6) but I'm stuck on the repetition side of things, if it's even possible
Since I have data in a first column, perhaps something like this is easier to achieve:
A B C D
2014 2015
Label A 1 x x
Label A 2 x x
Label A 3
Label A 4
Label B 1
The labels in A column are taken using QUERY, just a list of, for example, people - can I repeat them? The Xs would then be a singular query to get right data for column A,B, and C
There is rept for repeating a string a given number of times. It can be abused for other data by way of join and split, if you can pick a suitable delimiter (some character that isn't going to be present in the data). I use | as a delimiter:
=split(join("", arrayformula(rept(A2:A6 & "|", 5))), "|")
This puts the content of A2:A6 in a row, repeating each entry 5 times.
Similar trick to have the content of B2:B6 repeated but in a loop: 1, 2, 3, 4, avg, 1, 2, 3, 4, avg ... :
=split(rept(join("|", B2:B6), 7), "|")
Here 7 is the number of times the loop should be repeated.

VLOOKUP in a FILTER-ed range while automatically adding new rows

I have an easy-to-append monthly purchase log:
month prod count
-----------------
jan water 10
jan bread 20
feb bread 2
feb water 1
And I want to get a friendlier summary table:
prod jan feb
-------------
water 10 1
bread 20 2
Any idea how I can get this raport with new months in log appearing automatically as new columns?
I managed to get the month heads with a =ArrayFormula(TRANSPOSE(UNIQUE(FILTER(log!A2:A, log!A2:A<>"")))) and I am ok with entering the prod column by hand but I only managed to have a formula per column for count. And that means I need to drag the formula with each new month added to the log...
Any ideas? Thanks!
Try this formula:
=QUERY(A:C,"select B, sum(C) where A <> '' group by B pivot A")
See more info here:
https://developers.google.com/chart/interactive/docs/querylanguage
Use number of months instead of names to get 1, 2, 3 from feb, jan ordered alphabetically

Conditional array formulas

I have a massive dataset and am preparing a dashboard based on this dataset.
On my dashboard, I have a drop-down menu that allows me to select a month of my choice, from Jan to Apr.
Visitor Jan Feb Mar Apr
Jenny 2 3 0 1
Peter 2 0 1 3
Charley 0 2 4
Charley 1 2 2 3
Sam 1 4 2 3
Peter 2 2 5 0
John 3 3 6 9
Robin 4 0 7 0
I am looking for a formula that will give me the number of unique visitors who have been active at least once in the month that I choose from the drop-down menu.
Hoping this is really clear, but if not, please feel free to shoot back your questions.
This may be easier with Excel 2013, but if the results you want from your example are 6, 5, 5, and 5 for Jan>April respectively then perhaps:
Create a PivotTable from multiple consolidation ranges (example how here and for VALUES choose Sum of Value.
Count the non-zero values in the PT by column with a formula such as:
=COUNTIF(H5:H10,">"&0)
The above however would not be convenient for repetition each month, though a whole year might be prepared at one time.

Resources