I have a spreadsheet that looks like the following
TABLE 1
ID/Month | May | June | July | August | September | October
ID101 | 30 | 50 | 50 | 80 | 20 | 60
ID201 | 20 | 30 | 10 | 40 | 30 | 50
ID101 | 10 | 50 | 60 | 80 | 70 | 20
ID301 | 20 | 80 | 70 | 40 | 40 | 70
ID101 | 30 | 70 | 80 | 50 | 90 | 50
ID301 | 80 | 20 | 30 | 20 | 60 | 20
TABLE 2
ID | Date | Value
ID101 | July | ?
ID201 | September | ?
ID301 | June | ?
? is the sum of the values in TABLE 1 if the IDs matches, and if the row of dates are less than or equal to the dates specified in TABLE 2.
So
for ID101 | July | ? I need to find the sum of values in row ID101 in TABLE 1 and May/June/July columns
for ID201 | September | ? I need to find the sum of values in row ID201 in TABLE 1 and May/June/July/August/September columns
How do I do a sumif like an index match table where I can look up conditions in column (IDs) and rows (less than or equal to dates)
You can use SUMPRODUCT function:
=SUMPRODUCT((J2=$A$2:$A$7)*(MONTH(K2&1)>=MONTH($B$1:$G$1&1))*$B$2:$G$7)
To convert your month names to correct number using MONTH(K2&1) formula you must specify a United States locale in the spreadsheet settings
You'll want to do three things:
Un-pivot your table ("wide" to "long") so that each value is in its own row, identified by an ID and a Month (this is a little tricky)
Give your month a numeric value (the MONTH() function comes in handy)
Use SUMIFS to check the ID column and the Month column.
Here's a working sample: Google Sheets link
Related
I have two columns, A and B, where A contains the number of values for corresponding value in B. I want to create column C that contains the number of values from A but with the value from B. So for example:
| A | | B |
| 2 | | 40 |
| 3 | | 60 |
Should produce:
| C |
| 40 |
| 40 |
| 60 |
| 60 |
| 60 |
So 2 of 40 and 3 of 60. This could be in memory (I only want to use C in a formula, don't really need it as an actual column) or as its own column.
Give a try on below formula-
=ArrayFormula(TRANSPOSE(SPLIT(TEXTJOIN("#",TRUE,REPT(B1:B2&"#",A1:A2)),"#")))
I am trying to build a spreadsheet to track and automatically calculate money when I am called out for work.
Here are the conditions:
Monday, Tuesday, Wednesday, Thursday - Standby Rate: £21
Friday, Saturday, Sunday, Bank Holidays - Standby Rate: £26
Monday, Tuesday, Wednesday, Thursday - Callout Rate: (Hours Worked * Hourly Rate) * 1.25
Friday, Saturday, Sunday, Bank Holidays - Callout Rate: (Hours Worked * Hourly Rate) * 1.5
I have a spreadsheet containing the following information:
Column A - Date | Date
Column B - Called Out | Checkbox, tick if yes
Column C - Duration | If called out, how long for
Column D - Calculation | Shows the calculation used to determine payment
Column E - Payment | Shows the payment
The sheet looks like this:
+------------+-------------+----------+---------------------+---------+
| Date | Called Out? | Duration | Calculation | Payment |
+------------+-------------+----------+---------------------+---------+
| 01/02/2021 | | | 21 | £21 |
| 02/02/2021 | | | 21 | £21 |
| 03/02/2021 | | | 21 | £21 |
| 04/02/2021 | | | 21 | £21 |
| 05/02/2021 | | | 26 | £26 |
| 06/02/2021 | TRUE | 2 | 26+((2*50)*1.5) | £176 |
| 07/02/2021 | TRUE | 1 | 26+((1*50)*1.5) | £101 |
| 15/02/2021 | | | 21 | £21 |
| 16/02/2021 | TRUE | 1.5 | 21+((1.5*50)*1.25) | £177.25 |
| 17/02/2021 | | | 21 | £21 |
| 18/02/2021 | | | 21 | £21 |
| 19/02/2021 | | | 26 | £26 |
| 20/02/2021 | | | 26 | £26 |
| 21/02/2021 | | | 26 | £26 |
+------------+-------------+----------+---------------------+---------+
I have had some success with the following formula to get the standby rates (K1 contains my actual hourly rate):
=SUM(IF(WEEKDAY(A2,2)>4,26,21),IF(WEEKDAY(A2,2)>4,(($K$1*C2)*1.5),(($K$1*C2)*1.25)))
But I need to make it account for Bank Holidays and perform a check to see if column B is TRUE, then if it calculates the payment as dictated above.
Any ideas?
Your constants are.
Standby Rate: £21 OR £26
Hourly Rate: £50
Always: Standby OR Called Out
Bank Holidays
Change your table and use this
=ArrayFormula(IF((WEEKDAY(A2:A22,2)>4)+(B2:B22=TRUE),26,21)+
IF((WEEKDAY(A2:A22,2)>4)+(B2:B22=TRUE),C2:C22*50*1.5,C2:C22*50*1.25))
My working spreadsheet is here
https://docs.google.com/spreadsheets/d/1N7d2-W7pRTqpO9L4DvSkmm4j7vaHpJZ2fMYAq-yVVPg/copy
I made it in a few stages and tried to make it as simple as possible.
First we determine day of the week based on date:
=WEEKDAY(A4,2)
I put it in Column C for illustration only
Then I make a table with rates for each day of the week (assuming that sunday is 1st day of the week) - you see this in columns J and K
Then I set daily rate based on day of the week and 2nd column of table:
=vlookup(weekday(A4,2),$J$1:$K$8,2,false)
I don't use arrayformula here, just copy down formula, so when it's national holiday or something, you can manually change rate.
Finally I calculate payment for each day.
I add standby rate to call out hours (if there are none it's just flat standby rate).
I multiply hours by 1,5 for days with 26 standby rate and by 1,25 for days with 21 standby rate:
=D4+B4*50*(if(D4=26,1.5,1.25))
I would like to get the SUM of the values of comma separated variables (Issued Items) in Google Sheet. Please see the table below;
+-----------------------+-----------+
| Issued Items | SUM |
+-----------------------+-----------+
| A-22, A-22, B-11 | 120 |
+-----------------------+-----------+
| C-33, 11, 22-X | 160 |
+-----------------------+-----------+
| 22-X, D-54, 22 | 110 |
+-----------------------+-----------+
Edited: The Values for each Item will be stored in another sheet. And how can I get the count of Issued items?
Please note that the Items may repeat in a single cell and may also have prefix and suffix which are needed to be counted as individuals.
+-----------------------+-------+
| Items | Values | QTY |
+-----------------------+-------+
| A-22 | 50 | 2 |
+-----------------------+-------+
| B-11 | 20 | 1 |
+-----------------------+-------+
| C-33 | 70 | 1 |
+-----------------------+-------+
| D-54 | 40 | 1 |
+-----------------------+-------+
| 11 | 30 | 1 |
+-----------------------+-------+
| 22 | 10 | 1 |
+-----------------------+-------+
| 22-X | 60 | 2 |
+-----------------------+-------+
It would save a lot of time and effort for me.
Please help and thanks in advance.
=SUM(ARRAYFORMULA(IFERROR(VLOOKUP(TRANSPOSE(SPLIT(D2, ", ")), A:B, 2, 0))))
={"QTY"; ARRAYFORMULA(IFERROR(VLOOKUP(TO_TEXT(A2:A),
QUERY(TRANSPOSE(SPLIT(TEXTJOIN(", ", 1, D2:D), ", ")),
"select Col1,count(Col1) group by Col1 label count(Col1)''", 0), 2, 0)))}
I have a sheet which im using to build product data. I need to handle some custom SKU's and id like to have them stored in a string like "XYZ,ABC,FGH" in an alternate sheet.
The generic products are generated in the other sheet for various sizes automatically. I would like on the end of this list to be able to take one of these automatic rows as a template and replace the SKU with one of the custom SKU's if they exist in the other config sheet.
So for example:
SKU'S | Name | Width | Height | Weight | Quantity
--------------------------------------------------
PARENT| X | 10 | 20 | 100 | 0
M1 | X | 10 | 20 | 100 | 1
M2 | X | 10 | 20 | 100 | 2
M3 | X | 10 | 20 | 100 | 3
M4 | X | 10 | 20 | 100 | 4
M5 | X | 10 | 20 | 100 | 5
Then append:
ABC | X
XYZ | X
FGH | X
Keeping the existing columns the other products use.
The X's are just a representation for the other columns I want to copy (ive added some further columns as example data). The only thing I want to change is the SKU. Its a duplicate apart from the SKU (which I want to replace) and the Quantity. The consistent one to copy and use as the template would be the row with PARENT as the SKU.
The result is to just be a new row underneath M5 row. These are additional rows to just be tagged onto the end except for a change in the SKU.
The import is a lot of duplication to the database which is the product attributes like width, height, depth, weight, etc. This is set in a sheet I made with the name VARS. So I would create a simple field in VARS for 'Custom Additional SKUs' in say VARS!$B$10 with the value 'ABC,XYZ,FGH'. These would then use the same columns as the SKU's in say a sheet called INVENTORY.
The end result would be something like:
SKU'S | Name | Width | Height | Weight | Quantity
--------------------------------------------------
PARENT| X | 10 | 20 | 100 | 0
M1 | X | 10 | 20 | 100 | 1
M2 | X | 10 | 20 | 100 | 2
M3 | X | 10 | 20 | 100 | 3
M4 | X | 10 | 20 | 100 | 4
M5 | X | 10 | 20 | 100 | 5
ABC | X | 10 | 20 | 100 | 0
XYZ | X | 10 | 20 | 100 | 0
FGH | X | 10 | 20 | 100 | 0
Final solution based on feedback to help others.
Based on the great input from pnuts I went with the following in column A underneath:
=sort(transpose(split(VARS!A1,",")),1,TRUE)
In column B:
=IF(ISBLANK(A7),"",QUERY(SKU!A2:F2,"select B,C,D,E,F",0))
Works like a charm!
Maybe try:
=sort(transpose(split(NamedRange1,",")),1,TRUE)
and next to the above something like:
=QUERY(SKU!A:F,"select B,C,D,E,F where A='PARENT'",0)
copied down to suit.
What I have is a sheet with data and I want to define a non-contiguous range that can be used to, as an example, create a chart.
As long as the range is rectangular it's pretty easy defining the range.
range := ASheet.Range['A1', 'B10'];
This creates a rectangular range with the top left corner at A1 and bottom right corner in B10. The problem is when the data isn't defined so that it can be selected with a single rectangle.
As an example we have this data:
+-------+------+------+------+------+
| Time | Col1 | Col2 | Col3 | Col4 |
+-------+------+------+------+------+
| 01:20 | 5 | 1 | 101 | 51 |
| 01:21 | 6 | 1 | 101 | 51 |
| 01:22 | 5 | 0 | 101 | 51 |
| 01:23 | 5 | 0 | 101 | 51 |
| 01:24 | 5 | 0 | 101 | 55 |
| 01:25 | 5 | 1 | 101 | 55 |
| 01:26 | 6 | 1 | 101 | 15 |
| 01:27 | 7 | 2 | 101 | 15 |
| 01:28 | 7 | 2 | 101 | 15 |
+-------+------+------+------+------+
If I for example wish to create a chart for Time, Col1 and Col2 then the range is simply ASheet.Range['A1', 'C10']. If I want to create the chart for Time, Col1, Col3 and Col4 it's not possible to create a range this way (since Col2 shouldn't be included).
In VBA it's possible to create the desired range by simply .Range("A1:B10,D1:E10"). Unfortunately there doesn't seem to be an equivalent way of defining a range in Delphi (Excel2010), in fact it seems to only support range with the format .Range[topLeft, bottomRight].
My question is: How do I define a non-contiguous range in Delphi?
After hours and hours of googling I stumbled upon the key part: Application.Union, when reading through the documentation for Range object for the nth time.
The solution is to use the Excel object method Union to make a union of two contiguous ranges in order to define a new range, which can be non-contiguous.
Example:
ExcelApp := TExcelApplication.Create(..);
...
Range1 := Sheet.Range['A1', 'B10'];
Range2 := Sheet.Range['D1', 'E10'];
Range := ExcelApp.Union(Range1, Range2);