Transpose and repeat column - google-sheets

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.

Related

How tranpose the data of more than 1 cell to only 1 cell on google sheets?

I have the following column :
A1
Miu Kei Yuk
3354
of
2018
8 April 2022
and need to separate it into 3 columns :
3354 of 2018 Miu Kei Yuk 8 April 2022
So the first and the fifth row are correct, but the row number 2, 3 and 4 needs to be in only 1 cell.
I tried transpose(A1:A5) but iu results in :
Miu Kei Yuk domingo, março 07, 1909 of 2018 8 April 2022
Is it possible to do it ?
try:
={A2&" "&A3&" "&A4, A1, A5}
or:
={A2&" "&A3&" "&A4\ A1\ A5}
For Portuguese Locale use this formula or Make a copy of this example.
={TEXTJOIN(" ";1;A2:A4)\
A1\
A5}
For United States locale use this formula
={TEXTJOIN(" ",1,A2:A4),
A1,
A5}

Compare performance range over the years for each unique school

I have a dataset with Year, school_id, Performance range (let's call it P_range).
Years range from 2019 - 2016
Performance Range from 0-5
Over 2000 unique school_ids
Basically I need to know how each school_id perfomed over the years within performance range.
Example:
YEAR
School_ID
P_Range
2019
1
4
2018
1
5
2017
1
3
2016
1
3
2019
2
1
I would like a fourth column that would look at the dataset and tell me in which year did its performance alter
2019-2018 this school decreased the range
2018-2017 this school increased the range
2017-2016 this school maintained the range
2016 would not compare to anything which is "First evaluation"
So at any given time, when we look at the results of 2019 we would see a sum of results being compared to 2018 and so on.
We need to know at a yearly rate, how many "maintained", "decreased" "increased" or "First evaluation"
If it were on excel this would be the formula:
=IF(B2=B3;IF(C2>C3;"INCREASED";IF(C2=C3;"MAINTANED";"DECREASED"));IF(B2<>B3;"1ST EVALUATION"))

How to get days between two dates in google sheet

I have been trying to get the number of days between two dates in google-sheet but sometimes it gives an integer and sometimes it gives another date. How to get only the integer?
Shared public sheet (sheet name DS):
https://docs.google.com/spreadsheets/d/10NzbtJhQj4hQBnZXcmwise3bLBIAWrE0qwSus_bz7a0/edit#gid=517697699
Example
SN COMPANY AppliedDate DaysSince Today
-----------------------------------------------------------
2 McDonald Feb 17, 2021 54 1
3 Nielson Feb 17, 2021 Apr 20, 1900 2 **This should be number NOT date
4 Edelman Feb 17, 2021 111 3
5 Upstart Feb 19, 2021 Apr 18, 1900 1
6 Root Inc. Feb 19, 2021 Apr 18, 1900 2
Required
For the column DaysSince I would like to have only number. I want number between two dates but sometimes the same formula works sometimes does not work.
Is there any other methods to get number of days between two dates?
Go Format > Number > Number to format you entire column. Your problem is that your format is set as Automatic.

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")

How to do mean in aggregate function with a condition in syntax in SPSS

I need to do mean in aggregate function by id and year with a condition. It should be simple - BUT couldn't make it.
An example:
ID year result
1 2011 50
1 2012 68
1 2012 45
2 2011 12
2 2011 80
2 2012 20
but I don't understand where to put the condition:
AGGREGATE
/OUTFILE='test'
/BREAK=CUSTOMER_ID CUSTOMERIDCD year
/test_mean_under60=MEAN(result) **IF result > 60**
/N_BREAK=N.
You can't do conditional statements in AGGREGATE. One way to accomplish your end goal though is to use TEMPORARY. and SELECT IF before the aggregate. Example below:
DATA LIST FREE / Id year result.
BEGIN DATA
1 2011 50
1 2012 68
1 2012 45
2 2011 12
2 2011 80
2 2012 20
END DATA.
DATASET DECLARE test.
TEMPORARY.
SELECT IF result > 60.
AGGREGATE OUTFILE='test'
/BREAK = ID year
/test_mean_over60 = MEAN(result)
/N_BREAK=N.
EXECUTE.

Resources