match, index, and concatenate to just one cell - arrays

I have a Google spreadsheet with two sheets, that I want to use to plan the calendar for my staff. One sheet is called "maquinas" (machines). The rows are the dates and the columns are the machines. Inside each cell there's the name of the operator of the machine. Like this:
Note that:
-some machines are inoperative some days (marked in black)
-there are special days when a machine that normally is operative has to close (cell H5)
-some operators have to operate several machines the same day
I have another sheet called "personas" (employees), where I want that each employee only has to look to one cell to know everything he has to do on each day (a list of all the machines that he must operate that day). This is an example of the desired result:
The order in which the machines appear in each cell is not important, as long as every one of them appears.
I have no idea about how to solve it. I have tried to bypass it creating a huge "tridimensional spreadsheet", with dates in the rows, employees in the columns, and machines in the sheets (in the third dimension), and concatenate towards the first sheet. It works, but then is very cumbersome and error-prone to make changes in the employees' daily work.
I have a bad feeling. Probably it will need code or array formulas, and the function concatenate doesn't work with arrays. And I have no idea of how to code in VBA, much less in Google Spreadsheets.

I think I have something you can try. Manually set up on your "personas" sheet,
enter the employee names in row 1 and the days in column A. Just as they are on
your example. Then paste this formula in cell B2:
=iferror(join(" ",(query(transpose(QUERY(maquinas!$B$1:$M$5 , "select * " )),"select Col1 where Col"&index(row())&" contains'"&B$1&"'"))))
Then drag the formula in B2 down as far as you need for days (If days are
not yet entered, they will show as blank.) Then highlight all the all the
cells with formulas in column B and drag it right to column J.
The "maquinas" is fine as is.
Let me know if you have a problem or need anything explained.
Here is a link to my working test spreadsheet. Make a copy and try it.
If you are using a different language, you may need to change the , to ;
in the formulas.
https://docs.google.com/spreadsheets/d/1jqDkYTy3rssqeKGJyLYzcMJ27c5X3a1P5osKkWPNOoM/edit?usp=sharing

Related

How to stack multiple columns into one, alternating rows - Google Sheets

I'm working on a Google Sheets document that has data stacked in columns in an unusual order (see image for reference)
I have what you see on columns A, B and C. But I want what I have on column E.
I have 8 pages with hundreds of data elements, all sorted in 3 columns like that and I'm looking for a formula or a custom script that would allow me to arrange the data in the right sequence.
I did research trying to find a solution, but none of the ones I found work well for this situation. The order of the elements is very important.
EDIT:
The data is not numbers. It's text. So sorting formulas wouldn't work, because it would sort it alphabetically and it would mess up the order
all you need is:
=FLATTEN(A1:C7)
with open ranges you can do:
=QUERY(FLATTEN(A1:C); "where Col1 is not null"; )
see: https://stackoverflow.com/questions/73767719/
try:
=SORT(ARRAYFORMULA(FLATTEN(A1:A,B1:B,C1:C)),1,1)

Unavoidable merged Cells - Fill blank cells with previous non-blank cell in same column

I have a roster table for a sports facility that has been formatted and has a column of merged cells (for human readability). Unfortunately I cannot change the formatting to eliminate the merged cells - too many people use it and in any case I'd need to overhaul all the formulas everywhere.
The cells contain names and merge 4 rows of a single column.
Formatted roster table w/ sample data
In a separate range I am trying to take this formatted info and put it into 1st normal form for analysis & graphing purposes. Since merged cells only contain the top-leftmost value, when trying to copy the column contents by formula (e.g. "=B14") it only shows the name in the top cell followed by 3 empty ones below.
I need to fill in the blank rows by copying the athlete names down. The other column formulas are working just fine.
For the life of me I can't figure it out. It has to be a formula and not apps script due to mobile use, and I've always been really bad with certain formulas and good with others. Usually I can make a guess at it, but this time I'm just lost.
Can someone point me in the right direction?
use:
=ARRAYFORMULA(IF(B2:B="",, VLOOKUP(ROW(A2:A), IF(A2:A<>"", {ROW(A2:A), A2:A}), 2, 1)))

How would I reference cells in order while moving down several cells in a formula on a separate sheet?

I have been at this for hours and it's kicking me. I'm trying to build a log for someone, and I have a sheet with standard data in table format. I need the next sheet to look a certain way so that it can be exported to PDF and continue looking like the log always has - which means that it will not be a standard table.
In the Log sheet, data is all on one row, in the PrintSheet the cell references will be placed in three rows, with a gap fourth row. Obviously, when you paste formulas in Excel, it picks the row you're in, vs the next row down in the referenced sheet. I've included the formulas that "work" in blue in the image for reference, but that would involve manually subtracting 3 (or 4 depending on which one I'm doing) to each formula (Formula for reference -- =Log!$A$1&": "&INDIRECT("'log'!A"&ROW()-3).
Is there a way to dynamically write this formula so it can just be copy/pasted every 4th row when they need more in the PrintSheet? Is it possible I need to be using an array formula (that is an area of Excel that I am deeply lacking in)?
Input Sheet (log) vs Output Sheet (PrintSheet) with formulas in blue
Use a bit of maths on the row number and pull the formula down as required:
=CHOOSE(MOD(ROW()-2,4)+1,Log!$A$1&":"&INDEX(Log!A:A,QUOTIENT(ROW()-2,4)+2),Log!$D$1&":"&INDEX(Log!D:D,QUOTIENT(ROW()-2,4)+2),"","")
Log:
PrintSheet:
If you have Excel 365, you can do it using the same method but as a spill formula:
=LET(logRows,COUNTA(Log!A:A)-1,
seq,SEQUENCE(logRows*4,1,0),
CHOOSE(MOD(seq,4)+1,Log!$A$1&":"&INDEX(Log!A:A,QUOTIENT(seq,4)+2),
Log!$D$1&":"&INDEX(Log!D:D,QUOTIENT(seq,4)+2),"",""))
In this case it counts the number of rows in the log so will expand as you add more rows.
The date and time can be done in a similar way.
Instead of row()-3 etc. have a look here whether this offset calculation helps:
Column A is the row in the output list and column B is the target row from the input list

How do I count the number of filled-in rows of a sheet based on the contents of a column?

Disclaimer: I am completely self-taught in google sheets
I have a sheet with columns for Date, Place, Title, etc. I am attempting to count how many rows have all their cells filled out, but only want to add up the rows within a certain time period (i.e. based on the "date" cells, which are column A.)
=SUM(ARRAYFORMULA(AND(
ISBETWEEN(A9:A,DATE(2022,1,21),DATE(2022,4,1)),
ISTEXT(B9:B)=ISTEXT(C9:C)=ISTEXT(D9:D)=TRUE)))
Currently I have this formula, which relies on an "AND" function to check that both the "ISBETWEEN" and "ISTEXT" criteria are met. However, I think this is keeping "ARRAYFORMULA" from working (I originally used "SUMPRODUCT", but that didn't work either.) If that isn't the problem, the fact that the different references aren't somehow logically connected makes wonder if this would method would even work to begin with...
So, what functions could I use to accomplish my goal?
I would prefer to contain all of this in one formula, but at this point I'd be fine utilizing a separate hidden sheet if what I'm doing isn't possible in just one cell.
(I've done my best to try and find if this has already been asked, but honestly I'm not sure how to properly phrase this, so sorry if this is a duplicate.)
try:
=COUNTA(IFNA(FILTER(B9:B; B9:B<>""; C9:C<>""; D9:D<>"",
A9:A>="2022-1-21*1"; A9:A<="2022-4-1"*1))
or use:
=SUMPRODUCT(B9:B100<>""; C9:C100<>""; D9:D100<>"";
A9:A100>="2022-1-21"*1; A9:A100<="2022-4-1"*1)

Parsing multiple dates from cell

I've got a spreadsheet that, for goofy reasons, has two columns next to each other in each of which is a series of dates, separated by ctrl-rtn linefeeds. They amount to a list of start/stop periods. There are reasons it's done this way, and will probably continue to be (I am open to other suggestions).
Given this structure, I'd like to be able to pull out the periods and/or period lengths. That is, given:
1/1/2015 1/3/15
1/15/15 1/20/15
2/3/15 2/7/15
(in only two adjacent cells) I'd like to be able to pull out at least:
2
5
4
and perhaps optionally break it up into six different cells (note that the lists will be variable lengths). This is much less important.
I am having a hard time figuring out how to even approach this. If I was in VBA I could regex it easy-peasy. I'm utterly new to Spreadsheet Scripts. Thanks so much for any help.
You should be able to split each cell (say A1) into three with:
=split(substitute(A1,char(10),","),",")
Repeat for the next (say A2), format as dates and in B3 and copied across to the right to suit:
=B2-B1

Resources