Sorting values of a selectable month - excel

I have the following Excel spreadsheet:
A B C D E
1 January February March February
2 Product A 500 300 800 500
3 Product B 400 500 250 300
4 Product C 600 100 700 100
In Columns A:C you can see the sales of three different products.
In Column E the user can select a month in Cell E1.
Based on this month the sales should be listed ascending.
I think this requires something like a VLOOKUP combined with a LARGE function since the matrix from the LARGE function has to switch based on the month in Cell E1.
Do you have any idea how I could achieve this?

You could use HLOOKUP to locate the month in E1 in the range B1:D1, but this just gives the value of the month ("February") and you need the position of the month (from 1 to 3) to find the right column B,C or D so I suggest using Index and Match as follows
=IFERROR(LARGE(INDEX($B$2:$D$4,0,MATCH($E$1,$B$1:$D$1,0)),ROWS($1:1)),"")

Related

Sort list by the difference between two values

I have the following Excel spreadsheet:
A B C D
1 Budget Actual Sort by Variancy (descending)
2 Product A 500 250 Product F
3 Product B 900 800 Product D
4 Product C 300 450 Product C
5 Product D 400 600 Product B
6 Product E 700 300 Product A
7 Product F 150 900 Product E
As you can see in Column A I have listed different products and in Column B I have their budget value and in Column C the actual value.
Now, I want to list those products based on their budget-actual-variancy in Column D in a descending order (starting from the highest positive variancy).
The only formula which comes in my mind is =LARGE(B2:B7,1) but it only sorts the products by the budget values (Column B) or actual values (Column C). Not by the difference between the two values.
Do you know any formula which I can use to sort the products in Column D based on their variancy?
Please note:
I know I could add a helper column in which I calculate the differences between Column B and Column C and then go with the LARGE function on this helper column but I am looking for a solution without such a helper column.
If one has SORTBY()(Currently only available with Office 365 insiders) then put this in D2 and it will spill automatically:
=SORTBY(A2:A7,B2:B7-C2:C7,1)
You can use the following (even when there are duplicate variances):
Formula in D2:
=INDEX($A$1:$A$7,LARGE(INDEX(($C$2:$C$7-$B$2:$B$7=AGGREGATE(14,3,$C$2:$C$7-$B$2:$B$7,ROW(1:1)))*($A$2:$A$7<>D1)*ROW($A$2:$A$7),),1))
Drag down.
In case of duplicate variances it will grab the last value in column A that represents that variancy and has not been featured in column D as yet.

Find row when Cumulative sum reaches certain value with condition

I have a table with 3 columns Date, Item and Number. Each row indicates how many items of each Item was received on that date. I am trying to find the date on which cumulative sum reaches 100 or more in that month. Each month will have a target for each item which will be saved in another sheet but for simplicity we can assume that its a fixed number of 100.
Example Data:
Date Item Number
1/2/2018 A 10
2/2/2018 B 10
2/2/2018 A 15
5/2/2018 C 25
6/2/2018 A 50
7/2/2018 B 10
7/2/2018 C 10
8/2/2018 A 25
9/2/2018 A 20
I am looking for the formula which should act on the data similar to above and give the result as 8/2/2018 which is the date on which the cumulative sum for Item A reached 100.
Each month will have different target number, and will have different number of entries.
I have tried using SUMIF and adding a additional column etc but this data is just part of a big data and each item limit is saved in a different sheet etc which is not easy to merge. Thanks in advance for help.
In Excel only, you can use Offset to develop an array of items and numbers containing 1,2,3...9 rows and then SUMIF to add each of them up. Then use Match to find the first one =100 and Index to find the matching date (in F2):
=INDEX(A2:A10,MATCH(100,SUMIF(OFFSET(B2,0,0,TRANSPOSE(ROW(A2:A10))-ROW(A1)),"A",OFFSET(C2,0,0,TRANSPOSE(ROW(A2:A10))-ROW(A1))),0))
Must be entered as an array formula using CtrlShiftEnter.
EDIT
To find the first sum which is >=100 (in G2):
=INDEX(A2:A10,MATCH(TRUE,SUMIF(OFFSET(B2,0,0,TRANSPOSE(ROW(A2:A10))-ROW(A1)),"A",OFFSET(C2,0,0,TRANSPOSE(ROW(A2:A10))-ROW(A1)))>=100,0))
Sum which reaches exactly 100
Sum which does not reach exactly 100 (the number in row 9 has been changed to 24):

Values of different time periods summed up and matched to certain dates

I have the following Excel spreadsheet.
The spreadsheet is used to plan sales campaigns. The user enters the start and end date of the sales campaign in Column B and Column C. In Column D the duration (number of days) is calculated from those dates. In Column E the user enters the revenue for the entire campaign. In Column F:L the user divides the revenue over the days of the duration.
In Column N each day of the year is listed.
In Column O the sum of the revenue based on the values in Column F:L should be calculated.
For example Campaign A starts at 2018-01-01, takes 4 days and therefore 300€ go to 2018-01-01, 100€ go to 2018-01-02 and so on ....
The same applies for all following campaigns.
Therefore, in Column O the sum of the revenue of all campaigns should be calculated so on 2018-01-02 to the 100€ from the second day of Campaign A the 120€ from the first day of Campaign B should be added. Thus, the total is 220€.
Do you know a formula that I can use in Column O which does exactly the calculation described above?
Sumproduct will iterate through testing whether the date is in the range, find where it lands in that range and return the correct value to be summed.
=SUMPRODUCT((N2<=$C$2:$C$5)*(N2>=$B$2:$B$5)*("Day " & N2-$B$2:$B$5+1 = $F$1:$L$1),$F$2:$L$5)

VLOOKUP when criteria exists mutliple times in matrix

I have the following Excel spreadsheet:
A B C D
1 Product A 500 Product A 500
2 Product B 800 Product A 700
3 Product C 450 Product A 300
4 Product A 700 Product B 800
5 Product A 300 Product B 400
6 Product C 300 Product B 250
7 Product B 400 Product C 450
8 Product B 250 Product C 300
In Column A and Column B the sales of differnt products are listed. A product can appear several times in Column A because each sale of the product is displayed.
In Column C the different products are sorted from A-C.
In Column D I want to use a VLOOKUP to get the sales from Column B for each of the products.
=VLOOKUP(C1,$A$1:$B$8,2)
However, since the products appear several times in Column A the VLOOKUP gives me only back one of the values.
How do I have to change the VLOOKUP to get each sale of the same product?
You cannot get desired result single VLOOKUP formula.
Use this array formula:
=INDEX($B$1:$B$8,SMALL(IF($A$1:$A$8=C1,ROW($A$1:$A$8)-ROW(INDEX($A$1:$A$8,1,1))+1),COUNTIF($C$1:C1,C1)))
Paste it into D1 and press CTRL+SHIFT+ENTER to change it into array formula, then pull formula down.
Another approach:
Insert one empty row above the data, then put this formula in column D (you can hide this column if you want to):
=MATCH(D2;INDIRECT("$A"& 2 + IF(D2=D1;E1;0) & ":$A$9");0)+IF(D2=D1;E1;0)
And this formula in column E:
=INDEX($B$2:$B$9;E2)
MATCH works similar to VLOOKUP but instead of the actual value returns the index of the result. INDIRECT("$A"& 2 + IF(D2=D1;E1;0) & ":$A$9") alters the searchmatrix based on the previous index of the search value (e.g. the first "Product A" is found at index 1 therefore the second "Product A" only looks in A3:A9, the second "Product A" is at index 4 thus the third "Product A" looks in A6:A9).
The second formula just extracts the value based on the matrix in column B and the index in column D.

Use date as a criteria in SUM or sumif function

I have two columns
Amount Date
100 01/01/2000
2000 01/12/2002
2000 02/02/2005
150 03/02/2000
250 05/03/2002
350 04/05/2006
I need result as follows
Total year
2005 - 2000
2000 - 250
2002 - 2250
2006 - 350
Can I use SUMIF function for this? If it's possible what criteria I have to put?
You can use the same formula as described in this thread: Summarize grouping by year and month
=SUMPRODUCT((YEAR(Sheet1!$B$2:$B$6)=A2)*Sheet1!$A$2:$A$6)
I supposed your data are in an array from A1 to A6 on Sheet1 and your results are on another Sheet, you put the year in column A and the formula in column B
If you add a column to the right of the date column containing
=year(B2)
(replace B2 with whichever cell contains the date in that row)
and fill that column down, then you can do a standard sumif on that column like
=sumif(C2:C10, 2002, A2:A10)

Resources