I am trying to write a PTO calculator in Excel and need help subtracting paid time off. The part I can't get to work is it subtracts in quarter-hour increments, but instead of using an HH:MM format, the times are scaled to 100.
Example:
| A | B
--|--------------|--------
1| Bank |50.00
2| CY | 6.40
|--------------|--------
3| Used | 9.50
|--------------|--------
4| Bank Remain |
5| CY Remain |
The Used would subtract from CY Accrued first until it is less than 0.25, then it will subtract the rest from Bank Accrued.
Thanks for the help. I did look for similar questions, but the only ones I saw calculated time in standard format (15 min intervals) not time proportioned to a 100 scale.
I'm not sure if this should go in it's own answer or not, since the principle is the same as the answer from #ReyJuna, but the execution is somewhat different. Using the table from the question:
| A | B
--|--------------|--------
1| Bank |50.00
2| CY | 6.40
|--------------|--------
3| Used | 9.50
|--------------|--------
4| Bank Remain |46.75
5| CY Remain | 0.15
Starting with finding CY Remain, if CY is greater than Used you don't have to worry about running out of 0.25 increment segments, so you can directly subtract using B2-B3 in the function below.
When CY is less than Used, you only want groups of exactly 0.25, so you can use the TRUNC() function to drop the decimals. The function is:
=IF(B2<B3,B2-(TRUNC(B2/0.25)*0.25),B2-B3)
Since you want to stop subtracting at CY less than 0.25, all you have to do is get the number of 0.25 groups in CY and subtract that. The rest that needs to be subtracted from Bank will be handled by this function:
=IF(B2<B3,B1-(B3-TRUNC(B2/0.25)*0.25),B1)
Notice the TRUNC(B2/0.25)*0.25 is the same, but is now subtracted from the value in Used. This gives you what is left over after the correct amount has been subtracted from CY first. Finally, when the Bank Remain function is false, meaning Bank PTO is not needed, then B1 is returned as it went unchanged.
This assumes using a formula instead of VBA and I have laid out the data in a simple table (see below) where the CY Old Balance is in cell B2.
| | A | B | C | D |
| |-------------|------|-------|----------|
|1| | CY | BANK | PTO Used |
|2| Old Balance | 6.4 | 50 | 9.5 |
|3| New Balance | 0.15 | 46.75 | |
The formula for the CY New Balance cell (B3) is:
=IF(B2>=D2,B2-D2,B2-0.25*INT(B2/0.25))
If the CY Old Balance is greater than or equal to the PTO Used, then I have assumed that the entire used amount is subtracted.
The B2-0.25*INT(B2/0.25) portion calculates how many whole portions of .25 are in your Old Balance and then subtracts that from your Old Balance giving you the CY New Balance.
The formula for the BANK New Balance cell (C3) is similar:
=IF(B2>=D2,C2,C2-(D2-0.25*INT(B2/0.25)))
The first part of the IF is based on the same assumption as above.
The C2-(D2-0.25*INT(B2/0.25)) uses the same "whole portions of .25" approach, then subtracts that from PTO Used to get what remains. That is then subtracted from BANK Old Balance to get the New Balance.
Related
I've spent pretty much all day trying to figure this out. I've read so many threads on here and on various other sites. This is what I'm trying to do:
I've got the total sales output. It's large and the number of items on it varies depending on the time frame it's looked at. There is a major lack in the system where I cannot get the figures by region. That information is not stored in the system. The records only store the customer's name, the product information, number of units, price, and purchase date. I want to get the total number of each item sold by region so that I can compare item popularity across regions.
There are only about 50 customers, so it is feasible for me to create a separate sheet assigning a region to the customers.
So, I have three sheets:
Sheet 1: Sales
+-----------------------------------------------------+
|Customer Name | Product | Amount | Price | Date |
-------------------------------------------------------
| Joe's Fish | RT-01 | 7 | 5.45 | 2020/5/20 |
-------------------------------------------------------
| Joe's Fish | CB-23 | 17 | 0.55 | 2020/5/20 |
-------------------------------------------------------
| Mack's Bugs | RT-01 | 4 | 4.45 | 2020/4/20 |
-------------------------------------------------------
| Joe's Fish | VX-28 | 1 | 1.20 | 2020/5/13 |
-------------------------------------------------------
| Karen's \/ | RT-01 | 9 | 3.45 | 2020/3/20 |
+-----------------------------------------------------+
Sheet 2: Regions
+----------------------+
| Customer | Region |
------------------------
| Joe's Fish | NA |
------------------------
| Mack's Bugs | NA |
------------------------
| Karen's \/ | EU |
+----------------------+
And my results are going in Sheet 3:
+----------------------+
| | NA | EU |
------------------------
| RT-01 | 11 | 9 |
+----------------------+
So looking at the data I made up for this question, I want to compare the number of RW-01's sold in North America to those sold in Europe. I can do it if I add an INDEX MATCH column to the end of the sales sheet, but I would have to do that every time I update the sales information.
Is there some way to do a SUMIFS like:
SUMIFS(Sheet1!$D:$D,Sheet1!$A:$A,INDEX(Sheet2!$B:$B,MATCH(Sheet1!#Current A#,Sheet2!$A:$A))=Sheet3!$B2,Sheet1!$B:$B,Sheet3!$A3)
?
I think it's difficult to do it with a SUMIFS because the columns you're matching have to be ranges, but you can certainly do it with a SUMPRODUCT and COUNTIFS:
=SUMPRODUCT(Sheet1!$C$2:$C$10*(Sheet1!$B$2:$B$10=$A2)*COUNTIFS(Sheet2!$A$2:$A$5,Sheet1!$A$2:$A$10,Sheet2!$B$2:$B$5,B$1))
I don't recommend using full-column references because it could be slow.
BTW I was assuming that there were no duplicates in Sheet2 for a particular combination of customer and region - if there were, you could use
=SUMPRODUCT(Sheet1!$C$2:$C$10*(Sheet1!$B$2:$B$10=$A2)*
(COUNTIFS(Sheet2!$A$2:$A$5,Sheet1!$A$2:$A$10,Sheet2!$B$2:$B$5,B$1)>0))
EDIT
It is worth using a dynamic version of the formula, though it is not elegant:
=SUM(Sheet1!$C2:INDEX(Sheet1!$C:$C,MATCH(2,1/(Sheet1!$C:$C<>"")))*(Sheet1!$B2:INDEX(Sheet1!$B:$B,MATCH(2,1/(Sheet1!$B:$B<>"")))=$A2)*
(COUNTIFS(Sheet2!$A$2:INDEX(Sheet2!$A:$A,MATCH(2,1/(Sheet2!$A:$A<>""))),Sheet1!$A2:INDEX(Sheet1!$A:$A,MATCH(2,1/(Sheet1!$A:$A<>""))),Sheet2!$B$2:INDEX(Sheet2!$B:$B,MATCH(2,1/(Sheet2!$B:$B<>""))),B$1)>0))
As you would need to make the match in memory I don't think it's feasible in Excel, you'll have to use a vba dictionary.
On the other hand, if the number of columns is fixed in your sales sheet, you can just format as table and add your index match in F.
When updating the sales data delete all lines as of line 3 and copy paste the update value. Excel will automatically apply the index match on all rows.
I have an excel sheet with 6 columns:
3 different cash flows (30%,60% and 10% of the project value)
3 columns with their respective dates
As an example, suppose total contract value is 100 USD, I receive USD 30 on 15.02.2019, USD 60 on 15.03.2020 and USD 10 on 15.03.2021. This is one row and 6 columns.
I want to present this information in 1 single chart/visualization. There are about 200 rows and the dates are not in a particular order, it's random.
When I try to combine the data X axis (dates) and all the 3 Cash flows (on Y axis), it doesn't make sense, it gets chaotic and moreover the dates only come up for the 30% Cash flow.
I want X axis with all the dates and on Y axis to have the cash flows with 3 legends (30%,60% and 10%) on their respective dates.So in nutshell , as an example the graph can show that on 1st January 2019 I had a total cash flow of 10 USD from 30% Cash flow, 5 from 60% and 2 from 10 %.I am not an advanced user in Excel so would appreciate your help! If I need to format my data to some particular way-I can do that as well.What graph should I use?
I am ready to use Power BI or any other free solution as well-if its easy there!
PS-I tried doing a combo chart and then making changes to data as well(but, still it doesn't work!) under Design>Select Data-tried everything!
You have to transform aka. normalize your data first.
What you have is 6 columns:
| Cash 30% | Cash 60% | Cash 10% | Date 30% | Date 60% | Date 10% |
| -------- | -------- | -------- | -------- | -------- | -------- |
| 30.00 | 60.00 | 10.00 | 20190215 | 20200315 | 20210315 |
What you want is the following structure, containing the same information as above, but in a normalized way:
| Cash flow pct | Date | Amount |
| ------------- | -------- | ------ |
| 10% | 20210315 | 10.00 |
| 30% | 20190215 | 30.00 |
| 60% | 20200315 | 60.00 |
Once your data is structured this way, visualizing it the way you're describing is straightforward.
Transforming the data is very easy to do using the Power Query editor of Power BI (or Excel for that matter). Post a new question tagged with "powerquery" if you need assistance in how to make a transformation such as this.
I am having some difficulty finding the optimal solution to a problem I am having with Excel. Right now, I have a large sheet which has time on one axis (column A is every date between 1/1/2018 to 1/1/2019), and in the sheet I have time using the h:mm:ss function in different cells on different intervals.
For example, for rows 1/1/2018 - 1/3/18, there is a starting time on 1/1/2018 (example, 8:00:00), and then an ending time on 1/3/18 (example, 16:00:00).
The time between those two dates and two times on those dates is what I am looking to calculate.
This is on a sheet with 2000+ rows, and each interval is different (some may be three days, some may be the same day). The difference between all of these is another column with location. This looks like:
Row 2) Date, Location [A], Arrival Time (8:00:00), Departure Time (blank)
Row 3) Date (the next day), Location [A] (the same as above), Arrival time (blank), Departure Time (16:00:00)
+---+----------+----------+---------+-----------+
| | A | B | C | D |
+---+----------+----------+---------+-----------+
| 1 | Date | Location | Arrival | Departure |
| 2 | 1/1/2018 | A | 8:00 | |
| 3 | 1/2/2018 | A | | 16:00 |
| 4 | 1/3/2018 | B | 8:00 | 16:00 |
| 5 | 1/4/2018 | C | 5:00 | 13:00 |
| 6 | 1/5/2018 | C | 5:00 | 10:00 |
+---+----------+----------+---------+-----------+
I need to calculate the time spend in Location [A] between Arrival time on one date to the Departure time on the next date.
Please let me know what you think the optimal solution is to this problem, I am open to anything!
+--------+----------+---------+-----------+------------------------+
| Date | Location | Arrival | Departure | Time Spent in Location |
| 1/1/18 | A | 8:00:00 | 16:00:00 | 8:00:00 |
| 1/2/18 | B | 8:00:00 | | |
| 1/3/18 | B | | 18:00:00 | 34:00:00 |
| 1/4/18 | C | 8:00:00 | | |
| 1/5/18 | C | | | |
| 1/6/18 | C | | 16:00:00 | 56:00:00 |
+--------+----------+---------+-----------+------------------------+
The post from above is dead accurate - The trouble I am having is from the time intervals for each location being different (and random). I am trying to simply have an additional column which calculates the time spent in each location - from there I will be collecting data on each location and how many hours will be spent there.
Also, a big THANK YOU for the help so far! I am shocked by how quickly comments were made - sorry for the time it took me to make the mock-up, hope it helps make my goal in this more clear.
Actual Snip from sheet
One possible solution is to use the following formula in E2 and copy down.
=IF(C3="",((A3+D3)-(A2+C2)),IF(D3<>"",D3-C3,""))
EDIT: D4-C4 changed to D3-C3 in formula above)
It works by combining the date to the time, doing a math operation as needed and then stripping it out. Tap in a couple of IF statements to deal with rows that are single line locations, or the arrival only. It also assumes the first entry cannot be a departure.
Credit to urdearboy for the correct custom formatting. You will need to format the cells of the column to be [h]:mm
OPTION 2
This assumes that locations can be repeated. The use of a helper column is used to create a unique combination.
In F2, use the following formula and copy down as required:
=COUNTIFS($B$2:B2,B2,$C$2:C2,"<>"&"")
The $ locking the cells is very important. Note how it creates an expanding range as you copy down.
now technically speaking you can combine the following into one monster formula, but it will be difficult to follow and therefore maintain if someone else has to deal with it or you come back to it at a much later date. So on that note I will break it into 2 more helper columns and formulas
In column G we will identify the first row where a unique location occurs. A unique location is created by compounding the location name and the unique ID number which is a count of how often it has occurred in the list so far. Ie. A1 is the first time there was an arrival at location A, E2 is the second arrival at location 2. In G2 place the following formula and copy down.
=AGGREGATE(15,6,ROW($A$2:$A$16)/(B2&F2=$B$2:$B$16&$F$2:$F$16),1)
Now that the arrival row is identified the same needs to be done for the departure row. The same formula can be used but change the 15 to a 14. In H2 place the following formula:
=AGGREGATE(14,6,ROW($A$2:$A$16)/(B2&F2=$B$2:$B$16&$F$2:$F$16),1)
Now that you have those locations identified, you can use the following formula to calculate time:
=IF(D2="","",(INDEX(A:A,H2)+INDEX(D:D,H2))-(INDEX(A:A,G2)+INDEX(C:C,G2)))
In the example, I placed it in I2 and then I copied F2:I2 down as required. but it could be placed in E2 and copied down just as easily.
If you do not want those additional helper columns in G and H, then you can substitute them into your formula for time and it will look like this:
=IF(D2="","",(INDEX(A:A,AGGREGATE(14,6,ROW($A$2:$A$16)/(B2&F2=$B$2:$B$16&$F$2:$F$16),1))+INDEX(D:D,AGGREGATE(14,6,ROW($A$2:$A$16)/(B2&F2=$B$2:$B$16&$F$2:$F$16),1)))-(INDEX(A:A,AGGREGATE(15,6,ROW($A$2:$A$16)/(B2&F2=$B$2:$B$16&$F$2:$F$16),1))+INDEX(C:C,AGGREGATE(15,6,ROW($A$2:$A$16)/(B2&F2=$B$2:$B$16&$F$2:$F$16),1))))
A tidied up version using the monster formula and therefore not needing column G and H formulas:
Remember to apply custom formatting to your time calculation column of [h]:mm
I thought I understood Excel well enough until my boss asked me to do something in excel that involved MATCH and INDEX and for the life of me I can't figure out how those functions work. Perhaps more appropriately, I can't figure out how they're working in the spreadsheet I'm looking at. I'll just walk you through carefully what I'm trying to do.
I start by creating a drop down list which is no problem. The drop down list is a list of what is essentially probability tables. To skip past some irrelevant math, each table will have a single number that is generated from all of the numbers in the table that will be used in some calculations in other parts of the spreadsheet. Each of these tables will also have a name (top cell) that matches an entry in the drop down list.
[If anyone knows how to format this question so that it is a little easier to follow my question please, please feel free to tell me how. I don't know how to format stackexchange questions for excel worth anything.]
So ultimately, I have two main tables that are preforming calculations. The calcuations themselves are irrelevant. What is relevant is that I need to be able to add in a value into the calculation that can change depending on what is selected from the drop down list. So let me try to give an example.
Lets say I have this table:
| Month | Balance | Interest Rate |
|:--------:|:-------:|:-------------:|
| January | 100.00 | 1% |
| February | 101.00 | 1% |
| March | 102.01 | 1% |
| April | 103.03 | 1% |
| May | 104.06 | 1% |
| June | 105.10 | 1% |
I want the interest rate to be dependent on the drop down list so that perhaps I have set up where my drop down lists is generated from a table of cells that is something like this:
| Interest Rate |
|:-------------:|
| Low |
| Medium |
| High |
And I have three tables labeled "Low", "Medium", and "High". Each of these tables will preform some calculation to get the final Interest Rate result that will be the number that shows up in the top table. So that if I select "High", my table will look like this instead.
| Month | Balance | Interest Rate |
|:--------:|:-------:|:-------------:|
| January | 100.00 | 5% |
| February | 105.00 | 5% |
| March | 110.25 | 5% |
| April | 115.76 | 5% |
| May | 121.55 | 5% |
| June | 127.63 | 5% |
I'm pretty sure I need index and match functions to do this. I'll even put in a formula that is doing something close to what I'm doing but I can't seem to decipher how everything is working.
=INDEX($U$13:$BM$416,MATCH(D12,$T$13:$T$416,0),MATCH($A$13,$U$11:$BM$11,0) + 1) * SUM(P:P)
I know that that doesn't mean much when you can't see the worksheet, but that formula is doing very close to what I need to do. I guess my ultimately question is just if anyone will help walk me through how I could accomplish this in Excel?
EDIT: Here's a better glimpse
Lets say I have these 3 tables that show interest rates for various different things (e.g. Auto Loan, Mortage, Credit Cards). The "######"s are just showing that there are values in those cells that are used to calculate the numbers at the bottom (0.01, 0.03, etc.). Lets also say that the range in excel for these 3 Data Tables is A1:I6.
| | DataTable 1 | | | DataTable 2 | | | DataTable 3 | |
|:------------:|:---------------:|:-------------:|:------------:|:---------------:|:-------------:|:------------:|:---------------:|:-------------:|
| Low,Interest | Medium,Interest | High,Interest | Low,Interest | Medium,Interest | High,Interest | Low,Interest | Medium,Interest | High,Interest |
|--------------|-----------------|---------------|--------------|-----------------|---------------|:-------------|-----------------|---------------|
| ####### | ####### | ####### | ####### | ####### | ####### | ####### | ####### | ####### |
| ####### | ####### | ####### | ####### | ####### | ####### | ####### | ####### | ####### |
| 0.01 | 0.03 | 0.05 | 0.02 | 0.04 | 0.06 | 0.10 | 0.20 | 0.30 |
I have a drop down list in A8 that contains the values Data Table 1, Data Table 2, and Data Table 3.
Lets say I have another table (Range is K1:M14) that looks like the 1st table in this question.
| Month | Balance | Medium Interest |
|:---------:|:-------:|:---------------:|
| January | $100.00 | 3% |
| February | $103.00 | 3% |
| March | $106.09 | 3% |
| April | $109.27 | 3% |
| May | $112.55 | 3% |
| June | $115.93 | 3% |
| July | $119.41 | 3% |
| August | $122.99 | 3% |
| September | $126.68 | 3% |
| October | $130.48 | 3% |
| November | $134.39 | 3% |
| December | $138.42 | 3% |
I wrote a formula that would determine how the 3% gets into the Medium Interest column.
=INDEX($A$6:$I$6,MATCH($A$8,$A$1:$I$1,0),MATCH($M$2,$A$2:$I$2,0))
It works when I choose Data Table 1 in the drop down list. It correctly places 3% which is the medium interest rate for Data Table 1 but when I choose either of the other 2 data tables, I get an invalid cell reference error. This is essentially what I need to do in my real spreadsheet.
Not sure I can say how to do what you want, but I can at least explain MATCH and INDEX and what your formula is doing with them - hopefully that will be enough!
MATCH(what,in_where,match_type) will return the index of what in the array/range in_where based on the match_type. The "best" match_type is 0 - like in your example - which means "exact match". The other options are 1 for "less than" and -1 for "greater than" - both requiring you in_where to be sorted...
So you first example MATCH(D12,$T$13:$T$416,0) is looking for the exact value that is in D12 in the range $T$13:$T$416.
INDEX(in_where,row,column) will return the value in the array/range in_where at row row and column column.
In your example, you are looking in the range $U$13:$BM$416 with the row/column given by the MATCHes... The first MATCH is looking for D12 roughly in column T and the second is looking for A13 roughly in row 11. (I.e. it looks like your "table" has headers in row 11 and "keys" in column T and you are searching for the intersection of their locations.) The +1 in the column will be to correctly align the index returned by the MATCH and the the column number for the INDEX...
Without seeing this (e.g. file somewhere like dropbox, or a screengrab) it is hard to say more - but I hope this helps!
Btw - INDEX & MATCH as a combination can also be a good replacement of VLOOKUP if your "key" column is to the right of the "value" column that you want (or if you have a wide table and any change within it force loads of recalculations)
UPDATE based on second part of question
The new example gives the formula: =INDEX($A$6:$I$6,MATCH($A$8,$A$1:$I$1,0),MATCH($M$2,$A$2:$I$2,0))
INDEX will return the value for the given row/column. In this example your "table" is a single row $A$6:$I$6 so you would need to give just row 1 here - you aren't looking in a grid, but just a list.
So, you are looking to find the interest value for the interest level (Low/Medium/High at the top of your table) in the right DataTable (selected from a drop down). There are a few ways to do this, depending on the control you have...
Create a real data grid with Low/Medium/High down the side, 1/2/3 along the top and the % inside - then use INDEX as originally planned... MATCH the selections to the row/column
If that is a bit much to do, how about creating a new "compound key" to your table... e.g. Row 2 could contain 1_Low, 1_Medium, 1_High, 2_Low, etc. You then use just one search, but with a concatenated key : =INDEX($A$6:$I$6,1,MATCH($A$8 & "_" & $M$1,$A$2:$I$2,0))
Otherwise, you would first need to find "DataTable 1" in the first header row and use that to restrict the range to search for the interest rate level header... It is a bit more complicated and would depend more on the details of your tables (e.g. are they all the same number of columns - Low/Medium/High - or do some have Very High)
The formula for the 3% in the Medium Interest column should be:
=INDEX(A6:I6,,MATCH(A8,A1:I1,0)+1)
This formula returns the value in the index array A6:I6. Since there is only one row of data in the array A6:I6, it is not necessary to specify the row position for the index function. That is why there are two commas together - the row reference is missing and is not necessary. MATCH supplies the column number reference for the function based on your drop down list, which will be the values 1, 4, or 7 and then +1 to move over one more column. MAKE SURE that in cell A1 you have "DataTable 1", in cell D1 have "DataTable 2", and cell G1 have "DataTable 3".
I've got an expenses form for my work which, to be fair, is terrible. I constantly have to fill them out and so I'm trying to add some formulae to speed up the process.
I want to sum the total money which would be a simple =sum(). However my problem is that the money is split into two columns | £ | p | which means that I end up with the pence column not over flowing into the pounds when it hits 100. I cannot change the format of the form.
Example:
currently
| £ | p |
| 5 | 20|
| 4 | 90|
Total| 9 |110|
required
| £ | p |
| 5 | 20|
| 4 | 90|
Total| 10| 10|
Does anyone have any suggestions?
Answer (StackOverflow wont let me answer for 8 hours...)
Sorted it :)
The £ column I've summed and added to the sum of the pence column divided by 100 rounded down to the nearest integer:
=SUM(POUND COLUMN)+ROUNDDOWN((SUM(PENCE COLUMN)/100),0)
and then in the pence total I've summed the pence column, divided by 100, and then found the remainder using the MOD function
=MOD(SUM(PENCE COLUMN),100)
Just convert one of the values e.g. multiply pence by 100 to work in pounds, or divide the pounds by 100 to work in pence. You can do this in your SUM formula.
Ok for the Pounds Column I would do:
=SUM(B1:B2)+INT(SUM(C1:C2)/100)
And for the Pence Column I would do:
=MOD(SUM(C1:C2),100 )
Where B1:B2 is the range of pound values and C1:C2 is the range of pence values.