Excel lookup same index different row - excel

I have a formatted table that contains information about areas, including sales for the month (and a heap of other columns containing other details). The table is the basis for graphs and pivot tables.
There is a row per month for each area, e.g.:
A B C D
1 Area Month Sales TwoMonthAverage
2 North 1 400 Manually entered
3 West 1 500 Manually entered
4 South 1 200 Manually entered
5 North 2 200 <calculate??>
6 West 2 200 <calculate??>
7 South 2 200 <calculate??>
8 North 3 100 <calculate??>
9 West 3 900 <calculate??>
10 South 3 600 <calculate??>
Each month, I want to calculate the "2 month average" sales for an area (being the average of the current and previous months).
I need to know how to get the sales for the same area for the previous month. The table rows will not necessarily be in the same area or month order. Needs to work in Excel 2013 and 2010.
Thanks
Blair

You could perhaps use SUMIFS to get the sum of the past 2 months sale:
=SUMIFS($C$2:C5, $A$2:A5, A5, $B$2:B5, ">="&B5-1)
This in D5 will give the sum of values that:
Have values in cells A above and including the current row, and
Have the month above or equal to the current month - 1.
You then only need to divide by 2 to get the 2 month average.

Related

vba concatenate three (dynamic) tables into a master one

I am wanting to concatenate separate tables from separate excel worksheets to create one master one.The issue with the tables is that they are dynamic ie, one table could have 100 rows, the other one could have 240, third table could have 50 for example. The tables themselves were generated by quite a few different processes, essentially they had individual filters applied and then were copied and pasted into these separate excel worksheets… ready to be used to concatenated!
I’ve managed to do all of the processes in vba so could prefer to stick with it. I don’t want to use power query (Because of connection issues and also wanted this to be automated). I also don’t want to get involved with pivot tables or do this in the sql database. This is for quite a few different reasons… and so would prefer to stick to VBA.
Ie
Table 1
Column a column b column c
Africa 100 4
Australia 0.1 5
America 200 7
Table 2
Column a column b column c
China 300 4
Australia 0.1 4
America 100 4
Table3
Column a column b column c
Bali 100 4
England 0.1 5
NZ 200 8
Result
Column a column b column c
Africa 100 4
Australia 0.1 5
America 200 7
China 300 4
Australia 0.1 4
America 100 4
Bali 100 4
England 0.1 5
NZ 200 8
If anyone has any recommendations, would love to hear

Excel Pivot Table: Different Subtotals for Different Value Fields

I have an excel pivot table with two summed field values. I need to subtotal the first one using sum and the second one using average. Here is the desired output:
Region
State
SumOfSales
SumOfUnitsSold
A
NY
100
5
A
NJ
200
3
A Subtotal
300
4
B
FL
250
4
B
GA
300
2
B Subtotal
550
3
So far the closest thing I've been able to find is a custom subtotal through the field settings for Region. But this adds two rows for subtotals. Any ideas?

Sum a Column if it matches a Criteria in one formula - is it possible?

I have two columns of revenue figures of different brands: Example
US UK
Brand 1 100 0
Brand 2 200 50
Brand 3 100 40
Brand 4 0 20
What I am trying to do is SUM the UK column IF and only if US AND UK are bigger than 0 (Revenue>0), Therefore my output would be 90.
How do I do this in one formula - is it possible?
Thanks
Try SUMIFS() like.
=SUMIFS(C2:C5,B2:B5,">0",C2:C5,">0")

Calculate 3 month Average on the base of CustomerID

I am trying to calculate three month average sales in excel w.r.t customerid in excel. I tried by doing it by AverageIfs function but nothing helped.
A B C
Orderdate sales customerid
5/15/2019 7 1
5/15/2019 48.5 1
4/15/2019 92.94 1
3/17/2019 102.85 1
3/18/2019 49 1
3/18/2019 119.95 1
2/18/2019 58.96 1
1/20/2019 14.6 1
5/16/2019 17 6
4/15/2019 148.5 6
4/12/2019 912.94 6
3/17/2019 102.85 6
9/18/2018 22.34 6
Formula I tried: =AVERAGEIFS(B:B,C:C,C2)
output expected:
customerid average(3 months)
1 49.48
6 359.48
Let's start from today's date and the date 3 months ago (Make it dynamic):
Remember to change the cell format from General to Date. Otherwise, it will show [43563]
Next use the date as part of our filter:
Now you should get the most recent 3 months data:
Copy the filtered data into a new spreadsheet
Copy the filtered data into a new spreadsheet
Copy the filtered data into a new spreadsheet
Next Step: get the distinct customer ID:
You will get this:
Last Step:
Use the function "AVERAGEIF":
Done!

How to combine vlookup and if else in Excel using formulas

I am trying to update the budget of resources for travelling in sheet 1 with their per day expenses in sheet2. I have to first verify the destination city, and then fetch the expenses of their travel from sheet 2 on the basis of the number of days they are travelling from (mentioned in sheet 1).
So, First the destination should be matched , once we get the row number (from sheet 2), then need to fetch the number of days from sheet 1, and on the basis of the number of days, fetch the expense from sheet 2
Sheet 1
Destination No of Days Total expenses(output)
City 1 1 150
City 2 3.5 200
City 3 2 400
Sheet 2
Destination Day 1 Day 2 Day 3 Day 4
City 2 100 150 175 200
City 1 150 250 350 450
City 3 200 400 600 800
I tried using vlookup, and nested if formula each, but I am not able to fetch the number of days
(IF(A2=Sheet2!$A$2,Sheet2!$B$2,IF(A3=Sheet2!$A$3,Sheet2!$B$3,IF(A4=Sheet2!$B$4,Sheet2!$B$4))))
The outcome is mentioned in the description. The column Total expenses in sheet 1 is the expected output.
Instead of VLookUp, try Index + Match
=INDEX(Sheet2!$B$2:$E$4,MATCH($A2,Sheet2!$A$2:$A$4,0),$B2)
Additionally you can use:
=SUMPRODUCT((Sheet2!$A$2:Sheet1!$A$4=A2)*(Sheet2!$B$1:$E$1="Day " & ROUNDUP(B2,0)),Sheet2!$B$2:$E$4)

Resources