Pivot table Calculated field - Sumif(s) between two dates? - excel

I'm attempting to calculate periods of out of stock for a fleet of rental equipment that has been in service for the past few years. I'm having trouble creating a sumif calculated field that sums units by date if date is between start and finish. My data looks like this:
Calendar |Start |Finish |Product |Units
2015-12-06|2015-12-6|2015-12-6 |Snowshoes |2
2015-12-07|2015-12-6|2015-12-7 |Snowshoes |1
Calendar - is a helper column I've added. It's sequential dates from launch to the present
Start - is the start Date of a rental booking
Finish - end date of the rental booking
Product - What's being rented
Units - How many are rented for that booking
I'd like the pivot table to look like:
Date | Snowshoes | Tent ... etc
2015-12-06 | 3 |
2015-12-07 | 1 |
I'm having a hard time setting up calculated field that will sum units if date is between start and finish, I keep getting formula errors.
Here's the formula I'm attempting to use to create a calculated field:
= sumifs( Units ,Start,">= Calendar" , Finish,"<= Calendar")
Is this even the best way to go about solving this problem? Is my formula the issue or is the entire approach flawed?
Adding screenshots:

From the data you have in the screenshots, this is what I came up.
The formula to use in column G:
=SUMIFS($E$2:$E$29,$A$2:$A$29,"<="&F2,$B$2:$B$29,">="&$F2)
The formula to use in column H (BTW, this is just for your reference. You can use either one of them):
=SUMPRODUCT(--($A$2:$A$29<=F2),--($B$2:$B$29>=F2),$E$2:$E$29)
From here, I created a Pivot Table like this:
Hopefully this can help you. But definitely let me know if I miss anything from your question.

Related

Use SUMIF with transformed text to number

So I have a monthly budget in Excel that I'm using to keep track of making sure all of my recurring bills get paid on time.
Let's assume I have a table formatted like this:
Bill | Due Date | Amount Projected | Actual Amount | Diff
Mortgage | 1st | $1,500 | $1,510 | -$10
Water Bill | 13th | $30 | $25.80 | $4.20
I get paid on the 1st and the 15th, and I'm trying to get two rows that give a sum of all of the bills that are due within the first paycheck, and a sum of those that are due after.
So I'm trying to use the SUMIF function, however because the DUE DATE column is text and not date so that I get the 1st, 2nd, etc, I'm not sure how to run a comparison on this.
So I have the formula to get rid of the th, nd, etc as:
=LEFT(B2, LEN(B2)-2)
If it didn't have the th, or nd, the SUMIF function would look like this:
=SUMIF(C2:C3, "> 15", B2:B3)
But I just can't figure out how to combine the two formula. Is there any special character that runs the transform on the cell where I can pass that into the formula, without having an intermediate cell somewhere to just hold the 1, or 13 for the date due?
I know there are other ways to do this like just sorting the columns by due date and then only selecting that range, but I'd like to not have to manually change a bunch of other "reporting" columns every time I add or remove a bill.
Thanks for any help in advance.
=SUMPRODUCT((left(B2:B3,len(B2:B3)-2)<15)*C2:C3)
SUMPRODUCT performs array like operations. As such avoid using full column reference such as B:B.

Historic data with missing dates in excel

Everyone,
I have an excell sheet which I have imported from my ERP program. It contains data about deviations in raw materials which were noted at specific dates.
There are 40 different materials and data was gathered throughout the last year.
The raw data looks like this:
Material name | Date | Deviation
Blue dye |2014.05.01| 50
Yellow dye |2014.07.02|-40
Blue dye |2014.07.04| 10
How can I transform this data to a stock-type chart which would should cumulitive deviations throughout the year (i.e. if Blue dye is always positive, how much had added up on each date).
I have figured out how to sum up the deviations with their previous values, I have also transformed the table so that all the materials have their deviations in a seperate row:
Material name1|Date1|Date2|Date3
|50 |-10 |20
Material name2|Date2|Date5|Date6
|5 |10 |-100
The problem is that the deviations don't happen on the same dates. If they were noted on the same day every week, this would be hard at all. In this case each material might not have a deviation for a month or two, while another has fluctuations every couple of days. I would need to somehow interpolate the data in between the dates, so that every day of the year is filled up.
I would appreciate any ideas, at this point I'm just stuck...
I thought the above may have been a little vague...i've done you a quick example at the link below - there are 3 tabs
1 for the raw data
2 to get the differences by date & material
3 to show stock holding each day by material (with no change should there be no change)
Assuming you wanted to graph this info by date/product you should have no problem doing this from the example.
hope this is of more help!
http://www.filedropper.com/materialexample
I would suggest using the original data but creating a table on a new tab, list the entire year in column A from A2 down then list the 40 materials across in B1,C1,D1...etc
Then Starting in first cell (B2) use SUMIF(AND functions to match the date in A2 and the material in B1. if there is a match then +/- the difference...perhaps start one cell lower down and use B1,C1 etc for the starting number to perform calculations...this should give you the holding at any one point.
Hope to have helped :)

How to build a line graph from two data sets in one table in Excel

I'm having an issue with Excel to which I can't find an accurate solution online.
I have this table:
PERSON | DATE | SIZE
==========================
Matt | 1-10 | 90.1
Jane | 1-10 | 71.3
Matt | 1-11 | 90.0
Jane | 1-11 | 71.0
Matt | 1-12 | 89.6
Jane | 1-13 | 70.2
And so on...
The thing is that this is the best solution for inputting this kind of data. I can't have two different tables, one for each person involved, because more people will probably be involved later on, and they all should be included in the same table.
As you can see, the idea is to monitor their weights. And this would be better achieved visually by a line graph that can tell each person what their progress is.
To this end, I would like to set up one graph that shows each person's progress individually as a different line. Like this:
I was wondering if there was any way of having Excel automatically build this line graph using this table but ordering values according to if cell X has value....
Not being able to find that, I also tried to set up an invisible table that would gather each set in its own column. For that, I was thinking of using an IF statement but I can't seem to find a way of getting that to populate a separate table, row by row, with the data from the original table. On the Internet I can only find how to add up all the values in a certain cell if another certain cell has X value.
I was wondering if anyone out there could give me a hand with this. Thanks in advance!
I would use a pivot table and pivot chart to accomplish this.
Insert a pivot table, select your entire data range (including headers).
Select Person, Date, and Size in the field list.
Under pivot table options select pivot chart and choose your desired chart type.
Move Person to Legend Fields, Date to Axis Fields, and Size to Values.
Right click the pivot table and go to PivotTable Options
Under "For empty cells show: " write N/A (this will let Excel ignore missing dates)
Here is an example of the blank values.
Let me know if any further clarification is needed.

Top X in Excel/PowerPivot Pivot Table Filtered by Column Label

I'm working on a Powerpivot Pivot Table listing sales for my company. The table looks like this:
Row Label: Client Name
Column Label: Year
Values: Sales Amount
So something like this (columns are Client Name, 2014, 2013, 2012)
Client 1 | $10,000 | $15,000 | $20,000
Client 2 | $15,000 | $12,000 | $30,000
I'd like the table and the years to be the same but I want to show the top 25 customers only for year 2014. If I tell it to take top 25 by customer sales it gives me top 25 by total sales given all the filters. How can I do this?
Master_cylinder,
after thinking about this I suggest creating separates calculated measures (Excel 2010, in 2013 it's Calculated Fields) for each year that will allow easy filtering. It might be tricky if you have way to many years, but this way you can be sure the results are filtered exactly how you need to:
So for each year, create this simple measure:
=CALCULATE([Sum of Sales], Sales[Year]=2014)
For other years, simple change the filter parameter at the end - replace 2014 with different years. Than drag all the measures on the table, so that you will get something like this:
When you are done, simple filter the table using regular filter option and pick those settings:
This will get you the results you need.
PS: This is the powerpivot table structure that I was working with, and link to my source file in Excel (2010):

Current price by cumulative progress against discrete values

I have to implement a set of formulas in Excel whose requirements seem to defy any logical or succinct way to do them with just formulas.
Short Description:
determine (and display) a timeline of a product's "effective" internal cost each day based on 1) the price paid for the product as a series of bulk purchases, and 2) the company's per-day consumption of the product using the price paid for each purchase, until the purchased amount is consumed and then moving on to the next purchase.
Simplified Details:
We have a sheet "PurchSums" with the product's bulk purchase history: (this is actually a pivot table)
| A | B | C | D |
1: Product Name Purch Date Rate Amount
...
23: Prod-Q 12/18/2012 $3.15 123.7
24: 1/24/2013 $3.05 748.2
25: 2/27/2013 $2.86 650.0
... ...
So initially, the internal price should be $3.15/pound until the first 123.7 pounds are used us, then it should switch to $3.05 and so on.
We have a sheet "Volumes" with consumption by day: (product consumption starts on March 1st)
| A | B | C | D |
1: Product Name 3/1/2013 3/2/2013 3/3/2013 ...
...
12: Prod-Q 87.2 77.1 101.5 ...
... ...
And I need to fill in formulas for the daily price sheet "Prices", which has the product's effective internal price for each day (filled-in by hand now):
| A | B | C | D |
1: Product Name 3/1/2013 3/2/2013 3/3/2013 ...
...
32: Prod-Q 3.15 3.15 3.05 ...
... ...
Note here that the price for "Prod-Q" changed to 3.05 on March 3rd. This is because its cumulative consumption reached 265.8 pounds (87.2 + 77.1 + 101.5) which exceeded the 12/18 purchase of 123.7 pounds and so switched from its price of 3.15 to the price of the next purchase from 1/24.
More Details:
The first sheet "PurchSums" is actually a pivot table, if that helps. Unfortunately, I don't think that it does, nor that GETPIVOTDATA(..) is going to be useful here (but I would be happy to be wrong). The information in it comes from another sheet "Purchases" which is just a list of all of the purchases:
| A | B | C | D |
1: Product Name Purch Date Rate Amount
...
11: Prod-Q 12/18/2012 $3.15 123.7
...
34: Prod-Q 1/24/2013 $3.05 748.2
...
67: Prod-Q 2/27/2013 $2.86 650.0
...
Additional:
First, I would like to do this as much as possible with Formulas in the existing cells/sheets. Plus I would like to minimize the number of additional sheets that have to be added to support this, as the workbook is already pretty substantial.
Secondly, yes I know that I could do this with VBA functions, and I will do that if there's no better way, but I would like to avoid that if possible because in my experience, populating the formulas of large sheets with massive VBA function calls can lead to some significant performance issues.
I would be grateful for any ideas on how to effectively approach this.
So what you are describing is a FIFO inventory accounting system. First In First Out. You might want to read up on it here:
http://en.wikipedia.org/wiki/FIFO_and_LIFO_accounting
and here:
http://accountingexplained.com/financial/inventories/fifo-method
Basically under FIFO you are making the assumption(whether right or wrong) that the first items that you are adding to your inventory are the first ones you are going to use up in your production. As opposed to LIFO which makes the assumption that the last items that you add to your inventory are the first ones that you are going to use up. That would only require a small change in my solution but let's focus on FIFO since that is your question.
So for every day that you operate you need to figure out how much of your inventory you used up and how much you paid for that inventory. So if you bought 20 items at 50 dollars and then another 20 items at 100 dollars the next day - and on the third day you used up 30 of the items in production, you used up (20 * $50 ) plus ( 10 * $100 ) = $2000 worth of inventory. 2000 / 30 = your effective cost of the product for the day(66.6666667). This effective cost is purely informational for the day - you probably wouldn't want to use it for any accounting - although you could with some rounding corrections - it would just be an indirect way to go about it.
So my solution uses a really ugly table. Basically for every day that you operate you need to figure out how much of your inventory you are using up and how much you paid for that inventory - and then divide it by the total amount used up in the day. Something like this should work for you:
=(IF(AND($E8>G$4,$E8>G$5),G$3,0)+IF(AND($E8>G$4,$E8<G$5),($E8-G$4),0))-SUM(G$7:G7)
=(IF(AND($E9>G$4,$E9>G$5),G$3,0)+IF(AND($E9>G$4,$E9<G$5),($E9-G$4),0))-SUM(G$7:G8)
=G8*$C8
=SUM(G13:G15)/G3
These formulas are all auto-fillable. And you could add on to this table as much space as you need(and probably improve it quite a bit). A small program in almost any language could accomplish this much easier and more intuitively than excel - but this works fine.
In practice, oftentimes nobody really knows which pieces of inventory are being used up and thus how much you paid for them. But the system persists nonetheless - usually the reason many accounting practices are done are the same as why the ancient peoples of the earth sacrificed animals - because that's how it's always been done - tradition and folklore. And for the most part it serves them quite well - routine sources of protein are healthy. I could think of some better ways to do it but - alas. Good Luck.
Assuming you know how to:
display product names on every row from the pivot table
extract lower- and upper-bound interval points from the Amount values from the pivot table
sum Volumes from all previous days from the correct row for each product
cover edge cases like volumes outside defined amount intervals
use Office 2007+ tables
use named ranges
...
For the first day, you want the maximum price = the first row for a given product name:
=INDEX(PurchSums[Rate], MATCH(this_row_product_name, PurchSums[Product Name], 0))
For every other day, you want to sum Volumes from all previous days and extract the rate from matching interval of Amounts for a given product name:
=SUMIFS(PurchSums[Rate],
PurchSums[Product Name], this_row_product_name,
PurchSums[Amount above], TEXT(sum_of_previous_volumes_for_product, "<=General"),
PurchSums[Amount up to], TEXT(sum_of_previous_volumes_for_product, ">General"))
Note that sum_of_previous_volumes_for_product > PurchSums[Amount above] and all the other conditions should be met in 1 row only, so we sum exactly 1 row.
Example:
For cell E16 the named ranges would be replaced / point to:
this_row_product_name = Prices[[#This Row],[Product Name]] = Prices[#Product Name] = $B16
sum_of_previous_volumes_for_product = =SUM(OFFSET(Volumes[[#Headers],[2013-03-01]:[2013-03-02]], MATCH(this_row_product_name, Volumes[Product Name], 0), 0)) = SUM($C12:D12)
So basically you want to summarize your "PurchSums" sheet and "Volumes" ones into one that combines the date fields??
If this is the case....
In your summary sheet make a row filled with the dates
Make a column for Purchase amount
Make a column for Volume amount
Under the Purchase amount use a match / index formula like this:
=index({Select the column C from "PurchSums"},match( {Select date from third sheet},{Select date column from "PurchSums"},0))
Similarly do the same thing for the Volume column.
Hope this gets you on your way if I am not far off on what you are trying to accomplish.

Resources