Array formula skipping blanks, importing adjacent cell - google-sheets

I am trying to automate simple tasks in my google sheets accounts:
(Link to sheet:here)
I would like all transactions under "Money In" in "Bank Statement" to automatically be entered into "Cash In" with the Descriptions, amounts and payment method carrying over. Similarly, I would like all transactions under "Money Out" in "Bank Statement" to be entered into "Cash Out" with the descriptions, amounts and payment method carrying over. Any help as to how this could be achieved would be greatly appreciated.

I don't understand your approach to the problem given the formula you're using. It seems to me that what you're asking should be a simple FILTER or QUERY, e.g.:
=FILTER(Bank!A4:B, Bank!B4:B<>"")
As player0 states, we don't know much without seeing your sheet and data, however. Theoretically, the above formula placed in Accounts!A4 (or A1, A2, A3) would do what you're describing, given that the range A4:B were previously blank.
UPDATE BASED ON COMMENTS AND SHEET:
Formulas in place:
=FILTER({'Bank Statement'!A3:B,'Bank Statement'!D3:D,'Bank Statement'!C3:C},'Bank Statement'!D3:D<>"",'Bank Statement'!E3:E="")
=FILTER({'Bank Statement'!A3:B,'Bank Statement'!E3:E,'Bank Statement'!C3:C},'Bank Statement'!E3:E<>"",'Bank Statement'!D3:D="")
This could have been done with a QUERY as well. But this may be easiest for you to understand. The setup between the curly brackets is a virtual array, which allows choosing the order of the columns. The two parts outside the curly brackets set the conditions (which are opposite depending on the page).

Related

Google Sheets Count Unique Dates based upon a criteria in different columns

I am trying to find a formula that will give me the count of unique dates a persons' name appears in one of two different columns and/or both columns.
I have a set of data where a person's name may show up in a "driver" column or a "helper" column, multiple times over the course of one day. Throughout the day some drivers might also be helpers and some days a driver may come in for duty but only as a helper. Basically all drivers can be helpers, but not all helpers can be drivers.
I've attached a link to a sample sheet for more clarity.
https://docs.google.com/spreadsheets/d/1GqNa1hrViX4B6mkL3wWcqEsy87gmdw77DhkhIaswLyI/edit?usp=sharing
I've created a REPORTS tab with a SORT(UNIQUE(FLATTEN)) Formula to give me a list of the names that appear in the DATA Tab.
I'm looking for a way to count the unique dates a name from the name (Column A of the REPORTS Tab) appears in either of the two columns (Column B and/or C of the DATA Tab) to determine the total number of days worked so I can calculate the total number of days off over the range queried.
I've tried several iterations of countif, countunique, and countuniqueifs but cannot seem to find a way to return the correct values.
Any advice on how to make this work would be appreciated.
I think if you put this formula in cell b7 you'll be set. You can drag it down.
=Counta(Unique(filter(DATA!A:A,(DATA!C:C=A7)+(DATA!B:B=A7))))
Here's a working version of your file.
For anyone interested, Google Sheets' Filter function differs slightly from Excel's Filter function because Sheets attempts to make it easier for users to apply multiple conditions by simply separating each parameter with a comma. Example: =filter(A:A,A:A<>"",B:B<>"bad result") will provide different results between the Sheets and Excel.
Excel Filter requires users to specify multiple conditions within parenthesis and denote each criterion be flagged with an OR condition with a + else an AND condition with a multiplication sign *. While this can appear daunting and bizarre to multiply arrays that have text in it, it allows for more flexibility.
To Google's credit, if one follows the required Excel Syntax (as I did in this answer) then the functions will behave the same.
delete what you got and use:
=QUERY(QUERY(UNIQUE({DATA!A:B; DATA!A:A, DATA!C:C}),
"select Col2,count(Col1),"&D2&"-count(Col2)
where Col2 is not null
group by Col2"),
"offset 1", 0)

Personal Finance Sheet - Copy and Paste Transactions

I'm trying to make a personal finance sheet. I would like to take the transactions from my bank and copy and paste them into "Current Results" Table. That way I don't have to manually put them in each day. The problem I am having though is the transactions are hard to read with all the numbers and other words that I don't need.
Here is my question...
Is there a way to check the "Transactions" table and change the transactions to match what is on the items list table? (See Desired Results Table)
View example spreadsheet here.
https://docs.google.com/spreadsheets/d/1dT7NtWysMOri9XxmYwCqJCNcL_-ZGtU0H1-BpFd3d4c/edit?usp=sharing
Another example here.
Change - PURCHASE WENDY'S CITY STATE CARD1234 - To ---> Wendys
Here are the formulas that I tried to get to work.
REGEXREPLACE(B8:B21,"something",K7:K23)
VLOOKUP(K7:K23,B8:B21,1)
Thanks for all of your help! I really appreciate it.
You can use the following formula
=ArrayFormula(REGEXEXTRACT(PROPER(B8:B21),PROPER(REGEXREPLACE(JOIN("|",G7:G),"\|+$",""))))
The "red words" you notice can not be extracted giving a #N/A error, since the sheets have no way of knowing them.
This can be remedied by adding them to the Items List
Functions used:
ArrayFormula
REGEXEXTRACT
PROPER
JOIN

Automated Number Distribution in Spreadsheets

Beginner here!
Here's a spreadsheet trying to show what I mean.
Suppose I have data for metrics in comparison to my competitors.
The metrics are sorted highest to lowest and I want to turn the names of the other companies into "Company 1, Company 2, etc." along with the order of the metrics. Myself ("Me") remains unchanged.
With every data set the competitors could be different companies, and I could be ranked in a different position. The number of competitors could range from 1-20.
Is there a way to automate the green fields in the spreadsheet so that I can just paste the data and the competitor numbering stays constant no matter where I appear in the list?
Thank you!
Lighter Torches, I've added a sheet named "Erik" to your spreadsheet.
I've placed an array formula into two cells: G5 and J5. They are the same except for the relative cell references. Since it is an array formula, the single formula in G5 "runs" the entire data set generated in G5:H; likewise, the formula in J5 "runs" the entire data set generated in J5:K. Array formulas do not require dragging/copying to other cells.
Here is the G5 formula:
=ArrayFormula(QUERY(SPLIT({"Me"&"^"&IFERROR(VLOOKUP("Me",A5:B,2,FALSE),"NA");"Company "&ROW(INDIRECT("A1:A"&COUNTA(FILTER(A5:A,A5:A<>"",A5:A<>"Me"))))&"^"&SORT(FILTER(B5:B,A5:A<>"",A5:A<>"Me"),FILTER(B5:B,A5:A<>"",A5:A<>"Me"),FALSE)},"^"),"Select * Order By Col2 Desc"))
In your sample data, the companies are already ordered by rank, best to worst. But in the real world, it seems that may not always be the case. With that in mind, you'll notice that I moved your top performer to the bottom in the second data set. I've written the formulas to account for this (i.e., they will order the companies in the correct order whether they were originally in the correct order or not).
Also, if "Me" for some reason doesn't appear in a raw-data list at all, it still shows up, unranked, at the top of the generated list. Again, I tried to account for real-world what-ifs in the formula.
Finally, I added a sheet-wide custom Conditional Formatting rule that applies bold to any occurrence of the word "Me," since it seemed you were doing that manually. As such, you can type the sole word "Me" in any cell in the sheet, and it will automatically be formatted bold. You can see this rule by selecting Format > Conditional Formatting from the menu, then clicking on the rule you see in the window that appears.

Count the number of missing required fields in Google Sheets

I have a Google Spreadsheet, used like a form, with multiple "Skills", all of which have 2 fields within them, a "required field" (used as a flag for if entry in that field is necessary) and a "Current field" (where the user provides input). I am trying to create a "Inputs Left" field which counts the number of "Required fields" which do not currently have an entry in the "Current field" across all of the fields (seen below).
To do this, I am currently using this formula (C12:P12 is the range with the values in it).
=COUNT(FILTER(C12:P12,ISODD(COLUMN(C12:P12)-COLUMN(C12)),C12:P12>0)) - COUNT(FILTER(C12:P12,ISEVEN(COLUMN(C12:P12)-COLUMN(C12)),C12:P12>=0))
The issue I am running into is when a "Skill" is not required, but a value is entered. With this formula, it counts this towards the number of inputs left, however I only want it to count towards this if it is a required field, while still allowing the user to input non-required skills (see below). In this situation, I would like to have it still show that 2 inputs a left (specifically skill 3 and 4 still need input)
I believe I could do this using a OnEdit() trigger with google scripts, but I would like to have it done using a formula if possible. I also believe I could do this with a series of normal If statements, but the actual document has many more "skills", and I believe an endless list of if statements would be hard to debug in the future. Any help is appreciated!
Ended up using a COUNTIFS statement:
=COUNTIFS(FILTER(C12:P12,ISODD(COLUMN(C12:P12)-COLUMN(C12))),">0",FILTER(C12:P12,ISEVEN(COLUMN(C12:P12)-COLUMN(C12))),"")
Because I imagine it's confusing why there is a ISEVEN(COLUMN(C12:P12)-COLUMN(C12)) (and ISODD), the reason is because I needed to do multiple of the "Inputs Left" Fields, and the "Required" field would switch between being even and odd, meaning I would need to edit the formula a lot. Using the COLUMN(C12:P12)-COLUMN(C12) normalized this, so the "Current" was always even and the "Required" was always odd.

using sum and countifs to get a percentage of 'yes'es across multiple columns by month and team - is there a simpler way?

I've been asked to create a summary for some google form responses, and though I have a working solution, I can't help but feel there must be a more elegant one.
The form collects data related to case checking - every month each team (there's 100+ teams) has to check a certain number of cases based on how many staff are in their team, and enter the results for each case they've checked in the google form. The team that have set this up want me to summarise the data by team, month, and section of the form (preliminary questions, case recording, outcomes, etc). There are 8 sections on the live form, ranging from 1-13 questions, all with Yes/No/NA/blank answers.
(honestly, it's not how I'd have approached setting all this up, but that is out of my hands!)
So they're essentially looking for a live monthly summary with team names down the side, section names along the top, and a %age completed that will keep up with entries as they come in (where we can also use importrange and query to pull the relevant bits into other google sheet summaries, as and when needed).
What I've currently got is this:
=iferror(sum(countifs('Form Responses'!$B:$B,$A3,'Form
Responses'!$F:$F,"Yes",'Form Responses'!$E:$E,">="&$B$1,'Form
Responses'!$E:$E,"<"&edate($B$1,1)),countifs('Form
Responses'!$B:$B,$A3,'Form Responses'!$G:$G,"Yes",'Form
Responses'!$E:$E,">="&$B$1,'Form
Responses'!$E:$E,"<"&edate($B$1,1)),countifs('Form
Responses'!$B:$B,$A3,'Form Responses'!$H:$H,"Yes",'Form
Responses'!$E:$E,">="&$B$1,'Form
Responses'!$E:$E,"<"&edate($B$1,1)),countifs('Form
Responses'!$B:$B,$A3,'Form Responses'!$I:$I,"Yes",'Form
Responses'!$E:$E,">="&$B$1,'Form
Responses'!$E:$E,"<"&edate($B$1,1)),countifs('Form
Responses'!$B:$B,$A3,'Form Responses'!$J:$J,"Yes",'Form
Responses'!$E:$E,">="&$B$1,'Form
Responses'!$E:$E,"<"&edate($B$1,1)),countifs('Form
Responses'!$B:$B,$A3,'Form Responses'!$K:$K,"Yes",'Form
Responses'!$E:$E,">="&$B$1,'Form
Responses'!$E:$E,"<"&edate($B$1,1)))/(countifs('Form
Responses'!$B:$B,$A3,'Form Responses'!$E:$E,">="&$B$1,'Form
Responses'!$E:$E,"<"&edate($B$1,1))*6),0)
It works, but it feels like a bit of a brute-force-and-ignorance solution. I've tried countifs & array, I've looked a pivot but I can't get the section groups, I've had a play with query but I can't figure out how to ask it to count all Yeses in multiple columns at once.
Is there a more elegant solution, or do I have to resign myself to setting up the next financial year's summaries like this?
Edit:
You can use plain array boolean multiplication to achieve the count, as trues are converted to 1s and false are converted to 0s:
=TO_PERCENT(ARRAYFORMULA(
SUM((f!F1:K="Yes")*(f!E1:E>=B1)*(f!E1:E<EDATE(B1,1))*(f!B:B=A3))/
SUM(6*(f!E1:E>=B1)*(f!E1:E<EDATE(B1,1))*(f!B:B=A3))
)
)
Renamed Form Responses to f
Numerator: SUM of
Question filter (f!F:K =Yes) and
Month filter (f!E:E is within month of B1) and
Team filter(B:B = A3)
Denominator: 6 times the SUM of
Month filter (f!E:E is within month of B1) and
Team filter(B:B = A3)
On this sample sheet that you provided you'll notice two new tabs. MK.Retab and MK.Summary.
On MK.Retab is a single formula in A2 that "re-tabulates" all of your survey data into a format that is much easier to analyze going forward. That tab can be "hidden" on your real project. It will continue to build the 6 column dataset forever. It would be a sort of "back end" sheet, only used to supply data to any further downstream analysis.
On MK.Summary is a single formula in cell A1 that Query's that dataset from MK.Retab and shows the percentage of Yes's by month by section by team in a format similar to what you proposed. I coded it to display the most recent month at the left, immediately to the right of the team names, and to push historical data off to the right. Even though people are often used to seeing time go from left to right, I find that the opposite method nice because it keeps you from having to scroll sideways to see the most recent data. It is very simple to change should you want to by getting rid of the "desc" that you find in the "order by" clause of the query string.
I find this kind of two step solution to problems like your useful, because while the summary migth not be exactly what you want, it's always easier to build formulas and analyses off of the data as laid out in the MK.Retab sheet.
As for the formula in MK.Retab, it is based on a method that I came up with a while back that constructs a large vlookup where the [search key] is actually a sequence of decimal numbers that is built by counting the number of rows in your real data set and multiplying by the number of columns of data that need to be repeated for each row. I built a demo some time ago that I'm happy to share with folks if you want to understand better how it works.
You said that your goal was to understand the formulas so that you could modify them going forward as needed. I'm not sure how easy that will be to do, but I can try my best to answer any questions you might have about the method or the solution generally.
What I can tell you is that some of the formulas are more complicated than they need to be because you just used Q1 Q2 Q3 etc instead of the actual questions. if you had a list of the questions asked somewhere (on some other tab, say), and what you wanted to call/name their corresponding "sections", it would make the formula significantly less complicated. As it stands, I had to use the appearance of the word "Comments", in row 1 to distinguish between where one section ended and another section began. The upside to that decision though, is that the formula I wrote is infinitely expandable to the right. That is, if you were to add another 100 columns worth of questions and answers to the sample set here, the formula would be able to handle that and break it out, so long as there was the word "Comments" between each section.
Hope all this helps.

Resources