excel:how to calculate average interval time - excel

+-------------+----------+----------+--------+------------------+
| customer_id | date | time | answer | missed_call_type |
+-------------+----------+----------+--------+------------------+
| 101 | 2018/8/3 | 12:13:00 | no | employee  |
| 102 | 2018/8/3 | 12:15:00 | no | customer |
| 103 | 2018/8/3 | 12:20:00 | no | employee  |
| 102 | 2018/8/3 | 15:15:00 | no | customer |
| 101 | 2018/8/3 | 18:15:00 | no | employee  |
| 105 | 2018/8/3 | 18:18:00 | no | customer |
| 102 | 2018/8/3 | 19:18:00 | no | employee  |
+-------------+----------+----------+--------+------------------+
I got a table whick looks like this and wanted to calculate average interval time for those who did not answer the phone.
for this example,the average interval time is:
{(18:15:00-12:13:00)+[(19:18:00-15:15:00)+(15:15:00-12:15:00)]/2}/2
the problem is I could only manipulate it in Excel...someone knows Excel please help!or any suggestion is fine,I am familiar with SQL.

I've entered your data as shown below, and added a time_to_next_call-column which calculates the interval until the next call to the same customer_id using the formula: =INDEX(C3:C$8,MATCH(A2,A3:A$8,0))-C2 for the first cell in the data set.
Then, list your customer IDs in a column, and use and AVERAGEIF-function to calcualte the average time_to_next_call for that customer_ID, as shown below:
As I've placed the customer_id 101 in cell A12, my function for calculating the average time_to_next_call is: =AVERAGEIFS($F$2:$F$8,$A$2:$A$8,A13,$F$2:$F$8,">0")
Adjust your ranges as appropriate to fit your workbook. Hope this helps

Related

Create descending list inlcuding duplicates based on filter criteria

Excel-File
| A | B | C | D | E | F |
---|--------------|-------------------|--------|-----------------|------------|------------|-
1 | Sales | Product | | Product | Sales | |
2 | 20 | Product_A | | Product_D | 100 | Product_D |
3 | 10 | Product_A | | Product_D | 90 | |
4 | 50 | Product_A | | Product_D | 50 | |
5 | 80 | Product_B | | Product_D | 50 | |
6 | 40 | Product_C | | | | |
7 | 30 | Product_C | | | | |
8 | 100 | Product_D | | | | |
9 | 90 | Product_D | | | | |
10 | 50 | Product_D | | | | |
11 | 50 | Product_D | | | | |
12 | | | | | | |
In Column B I have list of different products with their corresponding sales in Column A.
Products can appear mutliple times in the list.
Sales numbers can be equal for multiple products.
I want to use the value in Cell F2 as Filter-Criteria to create a descending list of the products in Column D and Column E sorted by the sales in Column A.
Therefore, I tried to add the FILTER function to the formula from this question:
=INDEX(SORT(FILTER(A2:B11,A2:A11=F2,""),2,-1),SEQUENCE(COUNT(A2:A11)),{2,1})
However, with this formula I get error #VALUE.
How do I need to modify the formula to make it work?
Simply add COUNTIF() inside the SEQUENCE():
=INDEX(SORT(FILTER(A2:B11,B2:B11=F2,""),2,-1),SEQUENCE(COUNTIF(B2:B11,F2)),{2,1})
Current view on OP side:
Due to unknown reason only Column D gets filled.

Dax measure for monthly running total on weekly granularity

I have to visualize an accumulated monthly budget on a daily level.
Means a running total for the individual month on a daily basis.
The budget targets are provided in a table like this:
+------+------------+--------+
| Area | Year-Week | Budget |
+------+------------+--------+
| A | 2020-01 | 50 |
| A | 2020-02 | 25 |
| A | 2020-03 | 50 |
| A | 2020-04 | 25 |
| B | 2020-01 | 50 |
| B | 2020-02 | 50 |
| B | 2020-03 | 50 |
| B | 2020-04 | 75 |
+------+------------+--------+
As you can see, the monthly budget for January is the sum of 2020-01 - 2020-04
The structure is provided in the calendar table. So I have the information on which week belongs to which month.
What I need to do is to create a dax measure that divides the weekly budget by the working days.
THe calendar has also the information of calendar days. For this purpose I have add this measure:
Working Days =
VAR vSelectedMonth =
SELECTEDVALUE ( 'Calendar'[Fiscal Month Number])
RETURN
CALCULATE (
COUNTROWS ( 'Calendar' ),
FILTER (
'Calendar',
'Calendar'[Fiscal Month Number] = vSelectedMonth
&& 'Calendar'[IsWorkingDay] = 1
)
)
Now, how can I divide the weekly budget by the working days for the corresponding week and than to accumulate this information for the whole month?
Based on the provided information the result should be something like that:
+------+------------+----------------+
| Area | Date | Running Budget |
+------+------------+----------------+
| A | 01.01.2020 | 10 |
| A | 02.01.2020 | 20 |
| A | 03.01.2020 | 30 |
| A | 04.01.2020 | 40 |
| A | 05.01.2020 | 50 |
| A | 06.01.2020 | 50 |
| A | 07.01.2020 | 50 |
| A | 08.01.2020 | 55 |
+------+------------+----------------+
Of course, if the corresponding date is not a working day, that value from the day before should be shown.
I am grateful for every help!
Please let me know if you need further information.
Best Regards

Excel Sum product values and stock then multiplie when multiple criteria

So I have this information:
+---------------+---------+-------+------------+
| Chocolate | Brand | Stock | Sale value |
+---------------+---------+-------+------------+
| Chokito | Nestlé | 1520 | $3,50 |
| Snickers | Mars | 3300 | $5,20 |
| Snickers 2 | Mars | 500 | $2,50 |
| Kit Kat | Nestlé | 2000 | $9,10 |
| Double Decker | Cadbury | 1000 | $2,50 |
| Idaho | Mars | 0 | $6,10 |
| Caramello | Cadbury | 350 | $7,50 |
| Cadbury Daily | Cadbury | 1000 | $3,10 |
| Almond Joy | Hershey | 500 | $1,50 |
| Twix | Nestlé | 999 | $4,50 |
| Zero Bar | Hershey | 488 | $5,50 |
+---------------+---------+-------+------------+
Wha I want to get the total stock value for each brand. I get these values by inserting a column of of stock * value then doing a Pivot Table
Cadbury $8.225,00
Hershey $3.434,00
Mars $18.410,00
Nestlé $28.015,50
But what I want to do is a formula in Excel that will get this same values.
I first tried using SUMIF but obvioulsy it didnt worked xD
I cant think of any other formula
Thanks for your help
Try,
=SUMPRODUCT((C$2:C$12), (D$2:D$12), --(B$2:B$12=G4))
For a dynamic length of data,
=SUMPRODUCT((C$2:INDEX(C:C, MATCH(1E+99, C:C))), (D$2:INDEX(D:D, MATCH(1E+99, C:C))), --(B$2:INDEX(B:B, MATCH(1E+99, C:C))=G4))
Alternative approach using sumif
Place the following in E2 and copy down
=D2*E2
this will give the value you of each individual chocolate level in stock
in column G generate a list of brands
in H2 use the following formula and copy down as needed
=SUMIF(B:B,G2,E:E)

Excel VBA extrapolate values

I have a file that has data stored in it the following way (weekly data example)
+----------+----------+----------+----------+----------+----------+
| | WK1 | WK2 | WK3 | WK4 | WK5 |
+----------+----------+----------+----------+----------+----------+
| DT Begin | 29.12.14 | 05.01.15 | 12.01.15 | 19.01.15 | 26.01.15 |
| DT End | 04.01.15 | 11.01.15 | 18.01.15 | 25.01.15 | 01.02.15 |
| XData | 50 | 10 | 10 | 10 | 50 |
+----------+----------+----------+----------+----------+----------+
My problem ist to aggregate the XData on a monthly basis. For that I want to break the data down for days and then calculate the average.
Edit: I changed the table as it was not clear what I meant. This averages to ((50*4)+(10*21)+(5*50))/31 = 22.90
+------------+-------+
| Date | Value |
+------------+-------+
| 01.01.2015 | 50 |
| 02.01.2015 | 50 |
| 03.01.2015 | 50 |
| 04.01.2015 | 50 |
| 05.01.2015 | 10 |
| 06.01.2015 | 10 |
| 07.01.2015 | 10 |
| 08.01.2015 | 10 |
| 09.01.2015 | 10 |
| 10.01.2015 | 10 |
| 11.01.2015 | 10 |
| 12.01.2015 | 10 |
| 13.01.2015 | 10 |
| 14.01.2015 | 10 |
| 15.01.2015 | 10 |
| 16.01.2015 | 10 |
| 17.01.2015 | 10 |
| 18.01.2015 | 10 |
| 19.01.2015 | 10 |
| 20.01.2015 | 10 |
| 21.01.2015 | 10 |
| 22.01.2015 | 10 |
| 23.01.2015 | 10 |
| 24.01.2015 | 10 |
| 25.01.2015 | 10 |
| 26.01.2015 | 50 |
| 27.01.2015 | 50 |
| 28.01.2015 | 50 |
| 29.01.2015 | 50 |
| 30.01.2015 | 50 |
| 31.01.2015 | 50 |
+------------+-------+
| Average | 22.90 |
+------------+-------+
After having done this calculation I want to summarize the data as follows for the entire year:
+-------+-------+-------+------+------+
| | Jan | Feb | Mar | ... |
+-------+-------+-------+------+------+
| XData | 22.90 | 22.00 | 23.1 | ... |
+-------+-------+-------+------+------+
Being a newbie in Excel VBA, I have extreme trouble doing this.
I know how to get to the value of a cell (Range.Value) but not how to find data in a particular week (as WK1 is there for 2014 as well) Range.Find with a date other than the one in the cell itself does not seem to work.
Whar I am asking for is a way to approach this problem. My particular difficulties are to:
Find the data in the worksheet
split the week values into day values (see table above)
Copy the data or hold it in some sort of data structure
calculate the average (this should be ease then)
fill in the data on a monthly basis
As you can see, I have trouble even getting started - any hints would be greatly appreciated. Maybe I'm thinking of this entirely too complicated? Thank you!

Adding Columns to Excel As List From Other Sheet Grows

Background
I'm creating a grade book in Excel for my wife. I have sheets for the overall grade, classwork, exams, and participation.
The three sections of work (classwork, exams, and participation) each have a variable number of items, and each item has a different number of points possible. Each section has a weight in the overall grade.
I have this up and running with a fixed number of items per section, but I'd like to create a template that can be updated from class to class and year to year.
Here's the problem:
On the classwork sheet, I'd like to be able to enter new assignments and their point value and have that automatically update the master grade sheet on my first sheet tab. Is there any way to add columns in a section of one worksheet (the master grade sheet) when new rows are added to another worksheet (the list of assignments)?
It is possible to achieve this without using VBA. The reason you will have difficulty acheiving this, however, is that you've violated normal form in the table you've already built. It appears the pertinent data you're looking for is each student's score on each assignment. If this if correct, the level of granularity you will want is on the Assignment, not on the Student.
There are some fairly quick ways to modify your existing work to account for this. I've written out some sample data below. Take a look and see if it helps.
Sample Original Table
+---------+------+------------+------------+
| Student | Quiz | Thumbnails | Watercolor |
+---------+------+------------+------------+
| Paul | 3 | 10 | 90 |
| Frank | 4 | 10 | 95 |
| Mary | 5 | 10 | 70 |
| Ellen | | 10 | 85 |
| Sue | 6 | 10 | 92 |
| Anton | 5 | 10 | 87 |
+---------+------+------------+------------+
Image of the data is below ( note I have highlighted the blank value ).
Sample Normal Table
+---------+-------------+-----------+-------+
| Student | Assignment | New_Score | Score |
+---------+-------------+-----------+-------+
| Paul | Quiz | | 3 |
| Frank | Quiz | | 4 |
| Mary | Quiz | | 5 |
| Ellen | Quiz | | 0 |
| Sue | Quiz | | 6 |
| Anton | Quiz | | 5 |
| Paul | Thumbnails | | 10 |
| Frank | Thumbnails | | 10 |
| Mary | Thumbnails | | 10 |
| Ellen | Thumbnails | | 10 |
| Sue | Thumbnails | | 10 |
| Anton | Thumbnails | | 10 |
| Paul | Watercolor | | 90 |
| Frank | Watercolor | | 95 |
| Mary | Watercolor | | 70 |
| Ellen | Watercolor | | 85 |
| Sue | Watercolor | | 92 |
| Anton | Watercolor | | 87 |
| Mary | ExtraCredit | 10 | 10 |
| Ellen | ExtraCredit | 8 | 8 |
| Sue | ExtraCredit | 9 | 9 |
| Anton | ExtraCredit | 10 | 10 |
+---------+-------------+-----------+-------+
Image of the data is below. The score column reaches back to your old table and grabs the score you've already entered for the students, so you won't have to do this all manually. The formula for this is =INDEX(non_normal,MATCH([#Student],non_normal[Student],0),MATCH([#Assignment],non_normal[#Headers],0)).
This assumes you've formatted the old data into an Excel DataTable ( ctrl+t ) and named it non_normal ( alt+j+t+i ). Note the unsubmitted assignment for Ellen comes through with a score of zero using this method. I've added a column named New_Score so that you are able to add new student-assignment submission combinations to the table without having to modify your old non_normal table ( which was the trouble in the OP ). With this column added, the formula in the Score column can be changed to =IF(NOT(ISBLANK([#[New_Score]])),[#[New_Score]],INDEX(non_normal,MATCH([#Student],non_normal[Student],0),MATCH([#Assignment],non_normal[#Headers],0))) which will take the New_Score value if available and the original score if not.
The orange cells are new student-assignment submission combinations. Note you do not need to add a row for every student, just add a row whenever a student submits an assignment.
Sample Assignments Table
+-------------+-----------------+
| Assignment | Points_Possible |
+-------------+-----------------+
| Quiz | 6 |
| Thumbnails | 10 |
| Wartercolor | 100 |
| ExtraCredit | |
+-------------+-----------------+
I've added the ExtraCredit assignment with a possible max score of zero/blank ( since not completing extra credit shouldn't count against a student )
Payoff - Back to the Original Table
+--------------+---------------+------------+------------+-------------+-------------+--------+
| Sum of Score | Column Labels | | | | | |
+--------------+---------------+------------+------------+-------------+-------------+--------+
| Row Labels | Quiz | Thumbnails | Watercolor | ExtraCredit | Grand Total | |
+--------------+---------------+------------+------------+-------------+-------------+--------+
| Anton | 5 | 10 | 87 | 10 | 112 | 96.6% |
| Ellen | 0 | 10 | 85 | 8 | 103 | 88.8% |
| Frank | 4 | 10 | 95 | | 109 | 94.0% |
| Mary | 5 | 10 | 70 | 10 | 95 | 81.9% |
| Paul | 3 | 10 | 90 | | 103 | 88.8% |
| Sue | 6 | 10 | 92 | 9 | 117 | 100.9% |
+--------------+---------------+------------+------------+-------------+-------------+--------+
Using the image below, you pivot your newly normalized data into a Pivot Table. ( alt+n+v ). Now, simply adding a new assignment to the normal_assignment DataTable will cause that assignment to appear in a new column when you refresh the Pivot Table ( alt+a+r+a ).
The % score on the right of the Pivot Table is calculated using the following formula ( with the sample Pivot Table starting in cell $M$2 ): =GETPIVOTDATA("Score",$M$2,"Student",M4)/SUM(assignment[Points_Possible])
I've uploaded the raw sample file for this to my public repo if you'd like to pull it and take a peek at the source. Credit to sensefulsolutions for text-to-table conversion.
Hope this is what you need!

Resources