I need to write a complex formula in excel (or if someone has a suggestion as to another program to use I'm open to it!) with multiple conditions based on where the item is stored.
Each item has a minimum and maximum par level calculated, but can be stored in multiple locations. The percentage of that par is calculated based on where that item is stored (See last image below). For example:
Item A is stored in Central location 1, Central location 2, and 2 External (aka non-central) locations. There is a total quantity of 100 Item A's.
Based on our scenarios, we would find that:
Central Location 1: 70%
Central Location 2: 20%
External Location 1:10%/# of external Locations
External Location 2:10%/# of external Locations
So our par level for that item in each location would be:
Central Location 1: 70 of Item A
Central Location 2: 20 of Item A
External Location 1: 5 of Item A
External Location 2: 5 of Item A
The left side are the storage locations for each item ID #. I need to distribute the total Min and Max to each location depending on the scenarios below
I could go through and do this manually for each item (Where is stored, what is the scenario, calculate) but there are 1,500 items all stored in various places. Is there any formula I could write to calculate where the item is and how much of the item would go to each area its stored in?
I've tried using various IF and matching functions but feel like I don't have any clue where to start.
Any help would be great!
Different Scenarios of where an item can be stored. Depending on storage locations, each location will get a different percentage of the total (to the right in the image above)
OPTION 1
Build out your reference table like above using the following formulas for columns M and N row 2 and copy down for as many items as you have
=SUMPRODUCT(($C$2:$C$11=$J2)*(LEFT($A$2:$A$11)="c"))
=SUMPRODUCT(($C$2:$C$11=$J2)*(LEFT($A$2:$A$11)="e"))
After that in your cell M2 using the following equation and copy down:
=IF($A2="external",IF(INDEX($J$2:$N$5,MATCH($C2,$J$2:$J$5,0),4)=1,0.2,0.1)*INDEX($J$2:$N$5,MATCH($C2,$J$2:$J$5,0),2)/INDEX($J$2:$N$5,MATCH($C2,$J$2:$J$5,0),5),IF(--RIGHT($A2)=1,IF(INDEX($J$2:$N$5,MATCH($C2,$J$2:$J$5,0),4)=1,IF(INDEX($J$2:$N$5,MATCH($C2,$J$2:$J$5,0),5)=0,1,0.8),0.7)*INDEX($J$2:$N$5,MATCH($C2,$J$2:$J$5,0),2),IF(INDEX($J$2:$N$5,MATCH($C2,$J$2:$J$5,0),5)=0,0.3,IF(INDEX($J$2:$N$5,MATCH($C2,$J$2:$J$5,0),4)=1,0.8,0.2))))
in order to get your max values, repeat the concept but change
*INDEX($J$2:$N$5,MATCH($C2,$J$2:$J$5,0),2)
to
*INDEX($J$2:$N$5,MATCH($C2,$J$2:$J$5,0),3)
The change tells it to grab the value from the 3rd column instead of the second. There will be multiple locations to do this.
OPTION 2
Build out your table on the right to look like the following using the formula beneath the picture.
Build out columns M and N as OPTION 1
Build out columns O:Q using the following:
=IF(AND(M3=0,N3=0),0,IF(M3=2,0.7,IF(N3=0,1,0.8))*K3)
=IF(AND(M3=0,N3=0),0,IF(M3=2,IF(N3=0,0.3,0.2),0.8)*K3)
=IF(AND(M3=0,N3=0),0,IF(M3=1,0.2,0.1)*K3/N3)
Repeat these fomulas in R:T changing K3 to L3
Then in column D and E use the respective formulas:
=INDEX($O$3:$Q$6,MATCH($C2,$J$3:$J$6,0),MATCH($A2,$O$2:$Q$2,0))
=INDEX($R$3:$T$6,MATCH($C2,$J$3:$J$6,0),MATCH($A2,$R$2:$T$2,0))
copy the formulas down as required.
OPTIONS 2 while more spread out is probably easier to read and thus maintain.
Related
I have Excel data taken from vendor.
I want to change the format of layout so that it would be easier for me to ingest this data to database such as (Postgre / Mysql)
There are thousands of file in this format as one file contain information of only sales in one date.
Is there a better or fast way to convert this data or is creating VBA the only way?
We could definitely do this in VBA!
On the other hand, why bother when it can easily be accomplished with excel formulas?
My assumptions:
You're dealing with data of variable sizes (number of regions and items)
Cells you show as merged are merged on the actual data.
I set this up to work with a max data range of row 100, but easy to change that.
Step 1)
Identify how many regions and items we have:
=COUNTA($D$4:$K$4) (Regions)
=COUNTA($C$6:$C$100) (Items)
Step 2) List Items, repeating for number of regions.
Use local line numbers rather than worksheet row numbers to make this more portable.
To make it repeat, we're going to divide line# by total regions, roundup, then index items using that. Don't forget error handling to identify when to stop listing items. From now on, all the rest of our formulas will have a If( *item column* <> "", *show stuff* , *don't show stuff* ) . We can gloss over that in future steps.
=IFERROR(INDEX($C$6:$C$100,MATCH(ROUNDUP(M5/$P$1,0),$B$6:$B$100,0)),"")
Step 3) Date is super easy:
Just pull the same date for each: =IF($O5<>"",$C$2,"")
Step 4) We're going to use the Mod() function to create a cyclic action with our regions.
It took me a while to play with the formula... so don't ask me what all the adjustments(translation and scaling) are for, just trust it works. =IF($O5<>"",INDEX($D$4:$K$4,2*(MOD($M5-1,$P$1)+1)-1),"")
Step 5) "Quantity" and "Price" are the same formula, except "Price" has an extra "+1"
Quantity = =IFERROR(INDEX($D$6:$K$100,MATCH($O5,$C$6:$C$100,0),MATCH($P5,$D$4:$K$4,0)),"")
Price = =IFERROR(INDEX($D$6:$K$100,MATCH($O5,$C$6:$C$100,0),MATCH($P5,$D$4:$K$4,0)+1),"")
FINAL PRODUCT:
I have a data entry like thisData entries
Now, i need to find the smallest 10 values and also get the corresponding person and area and date along with it.
I used SMALL functoin to find the least 10 values. Then I used the index and match functions for getting their corresponding row entries. The problem is since some data entries are being repetitive, these functions are giving the row of the first 2 for all the remaining 2s. How to solve this
In F2 use Rank like this, so you have unique numbers:
=RANK(C2,$C$2:$C$21,1)+ROW()/1000
in G2 use Small, to pull the smallest of the ranked numbers and copy down 10 rows.
=SMALL($F$2:$F$21,ROW(A1))
Now you can pull person, date, real hours and area with an index match in H2, copied across and down.
=INDEX(A$2:A$21,MATCH($G2,$F$2:$F$21,0))
I am working on a distribution problem, analysing the volumes delivered to a set of stores (75 stores).
I have an Excel file as follows:
As you can see, each day does not contain the same stores, given that each store does not receive a delivery every day.
I want to get a new table that has the code of the store in the columns, and the information about volume and miles in the rows. Furthermore, I want to sum the values of the volumes given that they belong to the same store. In this example this would look like this:
As you can imagine, my spreadsheet is way bigger, having a total of 6500 rows and 800 columns. I was thinking about using the function combination of INDEX/MATCH, but I cannot see how to make it sum the multiple values for a given store in a given date.
While you need to extend this formula, you could use:
=SUMIF(INDEX($C:$F,MATCH($J2,$A:$A,0),),L$1,INDEX($C:$F,MATCH($J2,$A:$A,0)+MOD(ROW(),2)+1,))
if the table is build up like this:
From L2 you can simply drag down and to the left as needed ;)
EDIT
To also get the stores:
L1: {=MIN(IF(MOD(ROW($C$1:$F$6),3)=1,$C$1:$F$6))}
This is an array formula and must be entered without the {} but being confirmed with ctrl+shift+enter!
M1: =SUMPRODUCT(SMALL(IF(MOD(ROW($C$1:$F$6),3)=1,$C$1:$F$6),SUM((IF(MOD(ROW($C$1:$F$6),3)=1,$C$1:$F$6)<=L$1)*1)+1))
from M1 you can simply copy to the right.
And to get the dates (if non continuous or something like that)
J2: =MIN(A:A)
J3: =J2
J4: =SMALL(A:A,COUNTIF(A:A,"<="&J3)+1)
J5: =J4
then copy J4:J5 simply down :)
Dont put the stores in the columns, use VBA or similar to read the input files and normalize the data so that the output would be a table looking like
Store - Date - Volume - Miles
101 10/06/2016 520 120
102 11/06/2016 500 100
Then you can always lookup a store and date or pivot the data later.
Many times, I am required to provide some type of break-down to the customers - an example is shown in the attached figure.
I have a table of data ("TABLE DATA" - which is some type of pivot) + Customer provides its official form, its structure must be preserved (highlighted in yellow ). Basically, I need to separate the cost details of CODE "A" and CODE "B" into 2 separated sections.
Customer requires me to provided details for each individual Part (example shows Part A - "Break-Down Part A)
Is there anyway to put a"ITEM" from "TABLE DATA" into Code A and Code B ? the rests can be solved by Vlookup (Price, Quantity) - note: "ITEM" is non-duplicated values . Thank you very much
Number your rows in the breakout using =1 and =A1+1 and then just use the formula ="B-ITEM"&TEXT(A1,"000"). If you want to skip making a counter column you could use ="B-ITEM"&TEXT(ROW()-1,"000") to just use the current row number (minus 1 or however many you need).
If your items aren't sequentially like that, but still unique, I would recommend adding counters on the original tab similar to what you have, which would let you quickly find the 5th A or 7th B, something that counts the previous instances of your current type, and then adds 1. For Row 6 you could do =COUNTIF(A$1:A5,A6)+1.
I have a spreadsheet which is filled automatically from data in Microsoft Sharepoint. Unfortunately this data fills my location column as follows: IND;# ENG ;# USA if for example that particular input has 3 locations.
I then have drop down boxes (made via data validation) to filter the results down and give an optimum result. However when it comes to choosing location i can either choose ALL, IND, ENG, USA OR IND;# ENG ;# USA. If I chose, for instance, IND, then the options that are in multiple locations will not be returned (only the options that are in only IND will).
I was just wondering if there is any way, avoiding VBA, which will enable a choice of the individual location to return all options in this location, including the options that are availible in multiple locations.
** Please note that these multiple locations are contained within the SAME cell.
It's not possible as you have the question written. A drop down list created by data validation can only display a single result. If you chose 'IND' and wanted to show results for say 'IND' and 'IND, ENG' you would need to use something other than a drop down list or you need to do additional filtering based on the value selected down stream in your code/logic.
I'd say your best bet is to use VBA. This can be transparent from the user. When a user selects a value in the drop down list, vba can sort and filter the remaining drop down list based on what was selected (aka dependent drop downs)