Formula for computing total amount per day - excel

I have this Excel spreadsheet where in one of the columns I need to come up with a formula that will compute the total amount for a given day. This is a small snapshot of a huge spreadsheet:
Date/Time Time Amount Balance Total $ per day
9/30/2014 5:30 PM $5.20 $87.81
9/30/2014 4:23 PM $0.14 $93.01
9/30/2014 8:53 AM ($4.61) $93.15
9/30/2014 7:53 AM $5.20 $88.54
9/29/2014 5:08 PM $1.09 $93.74
9/29/2014 7:18 AM $1.09 $94.83
9/26/2014 5:31 PM ($4.61) $95.92
For this example the Total $ per day would be:
E2 $5.93
E6 $2.18
E8 ($4.61)
I'm guessing there is a formula that is much better than manually computing this by =SUM(X#:X#)?

In E2, put in the following formula:
=IF(A2<>A1,SUMIF(A:A,A2,C:C),"")
Then drag it down.
Basically, you're saying:
IF: There's a new date in column A (not the same as the date above it),
THEN: Sum all the values from column C that have the same value in column A
ELSE: Return an empty cell
That should do the trick.

If $87.81 is in D2 please try, in E2 copied down to suit:
=SUMIF(A:A,A2,C:C)
This assumes your dollar values are numeric formatted as currency.
The formulae will return a value for each row, even where there are several rows for the same date and a PivotTable may be preferable. Date/Time for ROWS, and Sum of Amount for Σ VALUES. This assumes Date/Time and Time are distinct columns.
For a PT the data need not be sorted in order.

Related

Excel calculate total time from punches

I want to calculate total time from same column containing date/time same row.
Use of pivot table or separate date and time into diff columns. I have the table as shown below.
First punch is at 8:48 last punch is at 19:53. I want to get the total hours between the 2 punches per day.
Any ideas how to do this?
Use the HOUR() worksheet function for this:
E.g.
B2 = 13:07
B3 = 18:07
Formula "=HOUR(B3-B2)" yields "5".

How to calculate the daywise average and multiply it to number of rows in that particular day

I have daywise excel data of four months which contains hourly data from 10 AM to 3 PM or sometimes 10 AM to 2 PM....1PM ..... like wise it is varying. The column A contains the date, Column B contains the time and column C and D has the data which i want to average for each day and multiply it to the number of occurrence.
For example If I have a data in column C and D for 17 Oct from 10 AM to 3PM (6 Hours)..Then i want to average these hourly data for a day and multiply it by 6. Since my interval of hourly data is not fixed, that is why i want a code which can average the daywise data and multiply it to the number of occurrence. I want to average the data 1 and data 2 for each day and to multiply its average by the number of occurrence of data in that particular day
I could not exactly get what does "average these hourly data" means since Average basically means summing all data within a day and dividing them to the occurrences. If you again multiply by the number of daily occurrence, you will get the summed value again.
Apart from above unclear point, un-merging all column B cells and filling all your rows with date data will be very helpful in order to form a quick sum or average formula based on the date conditions.
After doing above step, you may enter the below formula to E2 to get the sum of Col:C, for all data dated A2; 17-Oct.
=SUMIFS(C:C,A:A,A2)
And you may get the occurences on the date of your row data, you should use the formula and copy down:
=COUNTIFS(A:A,A2)
In combination of above 2 formulas, you may calculate the averages and/or date occurrences. I may write an exact solution if you may enter your requested values into COL:E and provide a screenshot.

EXCEL - How to spread X amount over N number of months

I am creating a revenue recognition model that tells the user the specific months X amount of revenue falls into based on specific start date. For example, I have an invoice dated 1/1/17 for $1200 total in monthly services that will be incurred over the next 3 months ($400 per month)
I want to create the model so the user enters the invoice date "1/1/17", the invoice amount "1200", and the number of months the invoice amount is spread over. In this case "3".
The model is setup with 24 columns which have the MM/YYYY header in each column. "Jan 2017, Feb 2017..Dec 2018". As the user enters the date, amount and # months, the values per month "400" will populate in Jan, Feb, and March 2017. The remaining months will have zero or be blank because no revenue will be allocated in those months.
I don't want anyone to give me the answer here, but I don't even know if this is possible in excel without using VBA. Some insight in how to get started would be helpful. Thanks!
This could be a start:
B1, B2 and B3 are the input cells. B1 must be a date not a string.
D1 to O1 are the months. The values must be dates, not strings, but could then be formatted to show only month and year. Format MMM YYYY for example.
You need only inputting D1 and E1 as dates 2017-01-01 and 2017-02-01, then select D1:E1 and fill to right. Then a series will be created having from step to step the difference of E1 - D1, which is 1 month in this example.
Formula in D2 is
=IF(AND(D$1>=DATE(YEAR($B$1),MONTH($B$1),1),D$1<=DATE(YEAR($B$1),MONTH($B$1)+$B$3-1,1)),$B$2/$B$3,"XX")
and can be filled to right as needed. In the example up to O2.
Now if you are changing any of the input cells, the values in D2 to O2 will also changing due to the formula.

Excel - how to get if a date is a specific day of the week?

I have a spreadsheet that tracks average file processing times over the course of a month. One of the macros and stats that we like to pull, is performance on Mondays (as the files are a little built up over the weekend). The spreadsheet is organized into columns by weekdays of the month:
The dates are formatted MM/DD/YYYY, so I would think Excel has a date function that it can determine weekday based on that date value.
Currently, I just have to manually tell the Macro which columns are Mondays, like so:
=AVERAGE(B20,G20,L20,Q20)
So, instead of manually, how would I get the average over the range of say, B20 to V20, only if the day of the week is Monday (the date cells are in row 1, so B1 to V1)?
To determine the weekday of a date in EXCEL use the =WEEKDAY() formula, which evaluates as 1 (Sunday) to 7 (Saturday)
e.g. If A1 contains 12/31/2016 (or 31/12/2016 if you're from where I'm from), the formual =WEEKDAY(A1) would evaluate to 7 (indicating that the last day of 2016 was a Saturday)
To apply this formula to your problem: (assuming that the dates are in row 1 and the values are in row 2)
insert a new row to hold the WEEKDAY() value (say, row 2)
in cell A2 type in =WEEKDAY(A1)
copy this formula as far right as necessary (to include all your dates)
Your average for Mondays is calculated as =AVERAGEIF(2:2, 2, 3:3)
Possibly, you can add a column called [Day Of The Week] and use the following formula to display the day.
TEXT(B4,"dddd")
Then add an 'If'statement to your result cell.
simply
=SUMPRODUCT((MOD(B1:V1,7)=2)*B20:V20)/SUMPRODUCT((MOD(B1:V1,7)=2)*1)
should give the average of all values from B20 to V20 if the corresponding cell in row 1 is a monday.
the first part sums the values of all mondays and the second part counts them (sum / count = average) ;)
If you have any questions, just ask.
If your date is in A1, you can use =Text(A1,"dddd") to determine the day of the week (it will return the name, "Monday", "Tuesday", etc.) so then you could do perhaps:
=If(text(A1,"dddd")="Monday",[do whatever],[do whatever]) (may need a helper row/column to hold the text of the weekday)
(Or use AverageIf() and use the Text() idea.)

How To automatically calculate Qtr Revenue given only two dates and Total Revenue

I could use some help writing an excel formula.
Case: Revenue is generated between 2 dates, Date A and Date B.
These dates could go into the next year and spread across quarters.
How can I split Revenue into Q1 Revenue, Q2 Revenue, Q3 Revenue, Q4 Revenue just based on my 2 dates and Total Revenue.
My thought was first identify which Qtr your dates fall into and then have an if statement that logically figures out the % and multiplies by the revenue.
Currently I'm using this formula to determine Qtr: =ROUNDUP(MONTH(DateA)/3,0).
Similarly for DateB.
Then, =if(DateAQtr=2, ((6/30/2013-DateA)/(DateB-DateA))*Revenue, 0)
There are clearly problems with this like, what happens if DateB(end Date) is in Q1 of the following year.
Denominator will always be Date B - Date A, giving you total days.
Numerator of Start Qtr is =(LastDayofQtr - Start).
Numerator of any quarters in the middle will be the full qtr length.
Numerator of End Qtr is =(EndDate - LastDayofPreviousQtr).
This is the logic. I'm trying to write into Excel formula to automate the process.
I made some named ranges to help see what is going on.
A2 = DateA, B2 = DateB, C2 = Revenue
A7 =DATE(YEAR(DateA),1,1) This is to establish the Q1 date for the DateA entered.
A8 =EDATE(A7,3) dragged down to cell A15 as in the picture. This returns the start of the next Quarter.
B7 =IF(AND(DateA>=A7,DateA<A8),A8-DateA,IF(AND(DateB>=A7,DateB<A8),DateB-A7,IF(AND(A7<DateB,A7>DateA),A8-A7))) This is checking how the dates compare to the Quarter start dates and returning the number of days our DateA and DateB date range contain for each Quarter.
C7 ="Q"&ROUNDUP(MONTH(A7)/3,0) dragged down to read the Qtr Start Date and return the corresponding Q#.
D7 =IF(B7=FALSE,"",C7&"-"&YEAR(A7)) returns the Q# and year when the days column is not false.
E7 =IF(D7="","",(Revenue/(DateB-DateA)*B7/Revenue)) This calculates the percentages of revenue that each quarter contains.
If you change the values of DateA or DateB everything still calculates properly. If you date range is larger than the two years displayed just drag the formulas down to expand the max range.
I hope this helps.

Resources