How can I convert data in multiple columns one after the other? - google-sheets

How can I convert the data in the image to the bottom?
Example Table

In a new column, you can use below formula to get the month where it has value greater than 0
=IF(I2>0,I1,IF(J2>0,J1,IF(K2>0,K1,"no value")))
You can repeat the column until "T" (December) for every row increment the cell reference
For eg.
=IF(I3>0,I1,IF(J3>0,J1,IF(K3>0,K1,"no value")))

Related

How to conditional format each row of a column based on corresponding value in another column

Please refer the image
I want the cell to be highlighted based on the value is less than or greater than the value in the benchmark column. I am not able to do that using conditional formatting custom formula. I have manually applied formatting for 02/01/2023 . I want the formatting to apply to the column with date = today() only.
Thanks :)
I can write a custom formula for each row of each date column. But is there any way a single custom formula that could format across rows and columns?
I'm guessing your fist value of 02/01/2023 and Activity1 is C2. Then for the whole range C2:Z (or whichever you have):
=C2>=$B2
Do this for one color for the whole range and it will drag automatically, you don't need to write it as an arrayformula. The "$" will always refer to the value in column B from the row it's positioned
if you are selecting whole range (C2:Z), try this for green and red respectively:
=(C2>=$B2)*(C2<>"")
=(C2<$B2)*(C2<>"")

Count cells if they have date information

I would like to get a count of my cells that have date information.
The format is: ['2020-12-19T00:00:00.939Z', '2020-12-19T00:45:20.499Z']
However, the rest of the cells in that column have [] - not blank, so I can't just do a COUNTIF(A1:A100,"*"). I would like to know how I can format this COUNTIF statement to grab only the cells with date and time data, because also this date could range from any day in the last year. I am using Google Sheets, the latest version.
You can take advantage of the "short" nature of the cells you don't want counted:
sumproduct(--len(A1:A100)>2)
This assumes that you have either have date data or cells like [].
You can try this:
=sum(Arrayformula(if(Substitute(A1:A12,"[]","")="",0,1)))
Substitute cells without date "[]" with empty cell ""
Check if cells are empty set to 0 or 1
use arrayformula() to apply formula to all cell rows
get the sum of the arrayformula() which will give you the count of non-empty cells in your range
try:
=INDEX(COUNTA(IFNA(SUBSTITUTE(A1:A100; "[]"; ))))

Get new array from old array so nth cell represents the sum of all cells in old array up to its index n

I'm trying to get a one-dimensional new array from an old one, where the nth cell in the new array is the value of the sum of all values up to the nth cell in the old array. In the array that I already have the data in each cell represents the profits per day. And I would like to get a new array where each cell represents the accumulated net profit up to that day.
Some things I tried to do to come up with a solution:​​​​
https://docs.google.com/spreadsheets/d/1qpBFtW6r8oQF75htpLQDhL8IxejuM7vmKN8qHOn-5vY/edit?usp=sharing
=ArrayFormula(SUM( OFFSET($A$2,0,0,ROW(A2:A)-1,1)))
=A3:A+INDIRECT("B"&TO_TEXT(ROW()-1))
For the first formula needs to be applied to every single cell. Instead, I just want a formula for B2 that returns an array to generates all the values underneath it.
And the second formula makes google sheets too slow to use for me.
Any help would be appreciated.
=ARRAYFORMULA(IF(LEN(A2:A), (SUMIF(ROW(A2:A), "<="&ROW(A2:A), A2:A)), ))

How to use index match formula that automatically expands in Google Sheets

In Google Sheets I am using a filter function to pull in Names into column A and a Timestamp into column B. Every time a second occurrence of the name shows up into columns A & B of the list I want column C next to the prior occurrence to reference the new timestamp. In column D I will then calculate the difference from the names timestamp and the next occurrence of that same name.
Currently I am using the following formula:
=IFERROR(INDEX(B3:B,MATCH(A2,A3:A,0)))
If I drag this formula down it does what I need it to do, but due to how many rows are being added to the first two columns, rows are being added to the bottom of the sheet due to the filter and the formulas keep needing to be dragged down. The durations in column D are being calculated with the following formula, that automatically arrays the results and automatically expands with the filter results:
=IFERROR(ARRAYFORMULA(IF(C2:C="","",C2:C-B2:B)))
I would like my index match formula to do the same, but it seems I cannot use the index formula with an arrayformula.
I attempted to achieve this by using a vlookup combined with an offset for the range. The first row is giving me the result I want, but all the subsequent rows are not referencing the offset range, probably because the offset isn't changing with each new array result here is that attempt:
=IFERROR(ARRAYFORMULA(VLOOKUP(A2:A,OFFSET(A2:B,1,0),2,FALSE)))
Any ideas how this could be accomplished by placing a formula in one cell, or would this have to be accomplished with a script?
I have added an example spreadsheet of the current method HERE
Thanks in advance for any help.
Formula
Instead of
INDEX, MATCH and OFFSET
try the following formula
=ArrayFormula(IFERROR(VLOOKUP(
TRANSPOSE(VALUE(REGEXEXTRACT(QUERY(TRANSPOSE(
IF(FILTER(ROW(A2:A),LEN(A2:A))<TRANSPOSE(FILTER(ROW(A2:A),LEN(A2:A))),
IF(FILTER(A2:A,LEN(A2:A))=TRANSPOSE(FILTER(A2:A,LEN(A2:A))),
TRANSPOSE(FILTER(ROW(A2:A),LEN(A2:A))),
),)
),,2000000),"(\d+)"))),
FILTER({ROW(A2:A),B2:B},LEN(A2:A)),2,0)))
Formula description
This part creates a square matrix showing the row number of the value that matches if it's below of the current row:
IF(FILTER(ROW(A2:A),LEN(A2:A))<TRANSPOSE(FILTER(ROW(A2:A),LEN(A2:A))),
IF(FILTER(A2:A,LEN(A2:A))=TRANSPOSE(FILTER(A2:A,LEN(A2:A))),
TRANSPOSE(FILTER(ROW(A2:A),LEN(A2:A))),
),)
This part takes the smallest row that matches the current row (the next occurrence of the row value)
TRANSPOSE(VALUE(REGEXEXTRACT(QUERY(TRANSPOSE( ),,2000000),"(\d+)")))
This part returns the related value, if any, otherwise a blank:
IFERROR(VLOOKUP( ,FILTER({ROW(A2:A),B2:B},LEN(A2:A)),2,0)))

Formula to find last value in row and label with Column Top

I'm using Google Spreadsheets. I'll be using this image from a very similar question.
http://i.imgur.com/jqcNW.png [a link]Google Spreadsheet Formula to get last value in a row
Instead of giving the value, I want the Column top to show. So the H column would look something like: 2 1 3 1 4
(The product numbers from Row 1)
If it helps =index(B2:G2;1;counta(B2:G2)) was the answer given to the original question. My values would be words instead of numbers. It'd need to track the last 'Yes' in the row with the column top being dates.
I think this should be easy:
=index($B$1:$G$1;1;counta(B2:G2)) - if you write this to the H2 cell, it should search the "N"th element in the FIRST row ($B$1:$G$1) - where N represents the value of non-empty cells in that row (B2:G2).
You can then populate this H2 formula downwards.
Let me know if this helps.

Resources