Search a huge range
I have a huge range (O15:BJ9309) that contains alternating cells of dates and payments in each row (date, payment, date, payment, date, payment, etc.) I need a formula that looks for dates that contain a specific year (ex. 2014) and adds up all payments to the immediate right of that date.
For example, in the range:
Date..............Pymt.......Date..........Pymt.....Date.........Pymt
12/18/2013....$400.....1/2/2014....$750.....2/1/2014...$320
In the above example, it would add $750 + $320 because both payments were made in 2014, but ignore a $400 payment made in 2013.
I’ll insert this formula in a hidden table, adjusting it to search for subsequent years:
Tax Year.....Gross
2014...........$80,000
2015...........$75,000
2016...........$93,000
Once that’s in place, I want to insert two cells into my Date and Payment’s page header, one labeled “Tax Year” and the second “Gross.” If “2015” is typed into the Tax Year cell, “$75,000 displays in the Gross cell. So I need a formula for that, too.
Many Thanks!
Given that your first column is "odd" (#15), you can try this array formula:
=SUM(IF(MOD(COLUMN(Rng),2)*(YEAR(Rng)=2014),OFFSET(Rng,0,1)))
Rng Refers to: $O$15:$BJ$9309
To array-enter a formula, after entering
the formula into the cell or formula bar, hold down
ctrl-shift while hitting enter. If you did this
correctly, Excel will place braces {...} around the formula.
Edit: If you replace the 2014 with a cell reference, you can vary the output easily according to the year of interest.
Do you have headers like those shown in row 14?
If so try using SUMPRODUCT like this
=SUMPRODUCT((O14:BI14="Date")*(YEAR(O15:BI9309)=2014),P15:BJ9309)
Related
I am trying to create a new scheduling spreadsheet and would like to automatically calculate each bartender's total hours for the week in column K. However, there are multiple shift lengths each night. How can I automatically pull an individual's total hours based on the specific shifts they worked each night? Sometimes there would be a third 'mid-shift' between the opening and closing (as seen on night 3). The number of shifts per week, shift lengths, and bartenders working will vary from week to week so I would like it to be universal.
My initial thought would be to calculate based on cell color but that doesn't seem to exist in Google Sheets. I tried downloading an extension to pull cell color but that didn't do what I wanted it to. Any help would be much appreciated!
Thank you!
Spreadsheet HERE
The layout of your roster sheet doesn't lend itself to easily calculating shift hours by employee. That's not to say that it cannot be done with the layout as-is but the layout unecessarily complicates the task.
The main complicating factors are:
shift types are identified by background colour
the identification of shift types/hours/duration for each night is inconsistent (e.g. the "mid" shift is described only in "Night2") which makes it difficult to anticipate whether any given "night" will have a "mid" shift or not.
the roster sheet includes blanks - for example: Cell F19 (Night2, Bar2) - this seems to be for aethetics
Roster Layout
This answer relies on a different, highly structured layout. The snapshot shows an example of "Night 3"; other nights are repeated above or below this. Rows 1&2 are frozen and not repeated.
Roster assignments are made for each shift in each bar.
e.g Bar1-Opening, Bar1-Mid, Ba11-Closing, etc
data validation is used to select the barkeeper names for each/any shift.
Shift times for each night are fully described.
There is a summary of shifts/hours/total hours by shift type
there is also a "Total Hours" value.
Calculations
I've moved the calculations to a different sheet for the sake of convenience.
The formula for Night1 (Cell D15)is:
=ArrayFormula((if(iserror(vlookup($A$15:$A$34,'Shift sheet'!$F$4:$F$13,1,0)),0,1*'Shift sheet'!$B$7)+if(iserror(vlookup($A$15:$A$34,'Shift sheet'!$I$4:$I$13,1,0)),0,1*'Shift sheet'!$B$7)+if(iserror(vlookup($A$15:$A$34,'Shift sheet'!$L$4:$L$13,1,0)),0,1*'Shift sheet'!$B$7))+(if(iserror(vlookup($A$15:$A$34,'Shift sheet'!$G$4:$G$13,1,0)),0,1*'Shift sheet'!$C$7)+if(iserror(vlookup($A$15:$A$34,'Shift sheet'!$J$4:$J$13,1,0)),0,1*'Shift sheet'!$C$7)+if(iserror(vlookup($A$15:$A$34,'Shift sheet'!$M$4:$M$13,1,0)),0,1*'Shift sheet'!$C$7))+(if(iserror(vlookup($A$15:$A$34,'Shift sheet'!$H$4:$H$13,1,0)),0,1*'Shift sheet'!$D$7)+if(iserror(vlookup($A$15:$A$34,'Shift sheet'!$K$4:$K$13,1,0)),0,1*'Shift sheet'!$D$7)+if(iserror(vlookup($A$15:$A$34,'Shift sheet'!$N$4:$N$13,1,0)),0,1*'Shift sheet'!$D$7)))
Note: this uses "Arrayformula` so a single formula fills the entire column for all employees
The same structure is used for other Nights" but cell references are changed to reference values for the relevant Night.
The formula for the the sum of the Nights (Cell C15) is:
=ARRAYFORMULA(if(D15:D34="",0,D15:D34+E15:E34+F15:F34))
Again, this uses an Arrayformula but it sums columns D, E, F. You can edit it to add references to the column for other Nights.
Some other formulas are described in the snapshot.
The "Proof" is designed to ensure that values from the Calculation sheet agree to values from the Roster sheet.
I work at a school and at the end of each semester we need to total up instructional hours for each student in each class, then get the sum for the whole class. We keep our attendance on a Google Sheet each semester, so I can use fancy functions to do this. This function has worked perfectly the last couple years:
=arrayformula(sum(countifs([data range],{"","T","*all *","*no *"})))
I run this at the beginning of a row and it counts all instances where a student (or the entire class) would be counted as present, but doesn't count anything else; just like I need it (students are counted as present if the cell is left blank). I run this function on each row (for each individual student) and then run a quick sum at the bottom of the sheet and it's all good to go.
Well, this worked because our classes were all 1-hour long every day. Starting this semester, they are either 1 hour and 20 minutes or 32 minutes depending on the day of the week (each class has one occurrence that is an hour twenty and one that is thirty-two minutes each week). So the above function no longer works as it just totals how many classes a student showed up for. I now need something that will do that, but also multiply the result of each cell (1 or 0) by either 1.33 or .53 depending on the day of the week. This can be done by referencing each column's header, which has the date attached and running a WEEKDAY parameter nested in an IF parameter like so (using a class that has the longer instance on a Friday for example):
(if((weekday(Z$1))=6, 1.33, 0.53))
I put that together into a function that works:
=countifs(Z2,{"","T","*all *","*no "})(if((weekday(Z$1))=6, 1.33, 0.53))
... but I will have to create a dummy column next to the column that has each date's attendance data, tailor the formula to the column next to it and copy and paste the formula all the way down the column. I should only need to change the formula once per sheet, but I'll still need to create dummy columns next to each date and then run this formula by hand on each column. After all that, then I can sum up each row. It works... but I want something less time-intensive and prone to error.
What I am hoping for is a function that does what I have now (for single cells), but runs each portion of this function on each individual cell across an entire row of data after I add it to the beginning of the row and then, preferably, sums up the total hours at the end (should just be able to add a SUM parameter to the beginning of the function?); all in a one-cell function. I have tried using an array like I had before (in the first formula above), but the problem there (there's probably more than one problem), is that I can't get the function to reference each cell's header and run the IF function, I can only get the array to work on the COUNTIF portion of the function. Maybe this whole thing needs to be a script instead?
I hope what I am asking for makes sense and here is a link to a sample of the data I am using:
https://docs.google.com/spreadsheets/d/12fTE_AMlKtlqc_KToYB5TkvpYwFzON9Q6vvRfnDlr0A/edit?usp=sharing
Thank you for reading and I hope there is a reasonable solution to what I'm asking!
try:
=INDEX(BYROW(B2:N15, LAMBDA(x, SUM(
REGEXMATCH(x, "^$|no .+|all .+|T")*
IF(WEEKDAY(B1:N1)=6, 1.33, 0.53)))))
Good day
I am very very new two paginated reports so forgive me if this is a silly question
I have a report that displays values for Mondays to Fridays based on the date selected from a date picker.
So basically
You select a date (Example 24 Nov) and the following table is displayed based on values pulled from SQL.
Now my question is how do I display the dates of the weekdays too?
So if the date selected is Thursday 24 Nov, in the column headers under the week day names it should give the corresponding date i.e Monday-21/11/2022, Tuesday - 22/11/2022, etc.
Below is a little snippet of the data
So the date picker is based on the ReportingDate column. The rows of the matrix consist of Region and Country and the values are the sum of Monday-Friday.
Any guidance would be greatly appreciated.
Edit: The day names are not obtained via an expression in SSRS. They carry over from the column headers in the data set.
Assuming you have some expression to get the actual day name already, you can leave that bit as it is.
Now, double click the column header "cell"/textbox to get a cursor in there, then click at the end of the existing fields/expression.
Now just put a space in and then right-click and choose "Create Placeholder". The placeholder dialog will appear.
This placeholder acts almost like a separate textbox to you can put whatever you want in there, click the '[fc]' button next to the Value property and then set this to whatever you want, e.g. =Fields!ReportingDate.Value.
Now go to the "number" tab on the same dialog box and set the format to the required date format.
If you want to edit this later, just double click the cell again but this time right-click the placeholder and choose properties.
The other way of doing this would be to add another row to your header and set that to be the date instead but then you have to mess around removing borders etc., sometimes this can be easier if layout is an issue but you have a couple of options at least now.
I managed to figure it out with the help of the following post.
These are the steps I followed
Get the date of the first day of the current week (Sunday's date) using the formula explained in the link
DateAdd("d",1- DatePart("w", CDate(Parameters!ReportingDate.Value)), CDate(Parameters!ReportingDate.Value))
Use DateAdd to add the corresponding number of days to get to a required weekday. That is for Monday add 1, Tuesday add 2,...
DateAdd("d",1,DateAdd("d",1- DatePart("w", CDate(Parameters!ReportingDate.Value)), CDate(Parameters!ReportingDate.Value)))
Format datetime to date and add new line to insert date below day name
="Monday" + Environment.NewLine + FormatDateTime(DateAdd("d",1,DateAdd("d",1- DatePart("w", CDate(Parameters!ReportingDate.Value)), CDate(Parameters!ReportingDate.Value))), DateFormat.ShortDate)
I have a sheet named Equipment with two columns G "Purchased Date" and H "Installation Date". A separate sheet named December is a calendar that is populated with data from Equipment when the dates match.
In the example below, I3 in December is 12/01/2020
=ARRAYFORMULA(IFERROR(INDEX(Equipment!A2:D,SMALL(IF(I3=Equipment!G2:H,ROW(Equipment!G2:H)-1),1))))
I would like to indicate in December that the data is a "Purchase Date" or an "Installation Date", preferably through conditional formatting (One is red font the other is blue font). The only solution I can think of is to force user to have two separate rows, one for "Purchase Date" and one for "Installation Date". Is it possible to avoid doing this?
Equipment
December
I came up with an answer that you may want to try. But it does involve a helper column for each day of the week. See my sample sheet here. I've used columns AS to AW on the far right for this. In AS, I put this formula:
=ArrayFormula(COUNTIFS(Equipment!$A$2:$A,D5:D,Equipment!$G$2:$G,$D$3))
This does a COUNTIFS in the Equipment tab for records that have the same Project Name as this row, and a purchase date equal to the date for this day of the calendar. This returns a 1 or a 0.
Then conditional formating rules are used to change the Project Name (in column D) to red text if column AS=1 (a purchase date), or blue text if not. If you predefined all of the text in this column as red (or blue) you would only need one CF rule for the whole column, making this easier to set up. You already have CF rules for your date headers, so they could override the default font colour (red or blue) assigned to the column, without needing an additional rule.
Note also that I found an alternative to your formula in D5 (and I5, N5...):
=iferror(query(Equipment!$A$2:$I,"Select A,B,C,D
where (G = date '"& text(D3,"yyyy-mm-dd") & "'
or I = date '"& text(D3,"yyyy-mm-dd") & "') order by A",0))
This returns all of the results for this day, with one formula.
I have a problem writing down a formula or a script in Google Sheet or Google App Script to find and count the values in a sheet where the number and references to the columns change.
I have a script that copy&paste the Sheet files for the staff shifts of every week from a Drive folder and merge them side by side (in horizontal).
In this sheet that contains all the shifts merged I want to count all the cells of the staff filtered only for handler and picker (column B, K, etc.) according to a specific date (row 3) for every hour.
Example: if today is 28/10/2020 find the right column with the same date in row 3 --> column E, count all the values from row 4 filtered by picker or handler for every hour (10 people at 05 AM).
Do you think that I can implement this with a formula (like a matrix, vlookup, etc.) or should it be written as a Script?
Thank you very much,
Marco
Please use the following
=COUNTA(QUERY({A3:I;J3:R},"select Col"&MATCH(A1,A3:I3)&"
where Col2 matches 'Technician|Picker' "))
Where B1 holds the date you wish to search for (28/10/2010)
Try the below formula. Replace date with your search date.
=COUNTA(INDEX(A4:R14,,MATCH(DATE(2020,10,28),A3:R3)))
This was earlier tagged as excel. This is how to "tackle" this in excel (office 365):
In a clear column use the following formula to get the unique hour-values that are in the column that equal today:
=UNIQUE(FILTER(INDEX(($4:$1048576,,MATCH(TODAY(),$3:$3,0)),INDEX(($4:$1048576,,MATCH(TODAY(),$3:$3,0))<>""))
In the column next to that type the following to get the result of the count of those unique values for that day:
=COUNTIF(INDEX(($4:$1048576,,MATCH(TODAY(),$3:$3,0)), FILTER (I:I,I:I<>""))
Where I:I in FILTER (I:I,I:I<>"") needs to be changed into the column you put the first formula.