SUMPRODUCT, CRITERIA and Blanks - excel

I would like to multiply each fund monthly returns * monthly assets in the following snippet of data
FUND Jan_returns Feb_returns Jan_Assets Feb_Assets
1 -2 3 200 300
1 2 7 250 500
1 5 2 3000
2 6 5 500 600
2 8 900
2 9 1500 1500
3 -6 3 100 1000
3 -7 4 660 520
For example, FUND 1 Jan_returns * Jan_assets = 15100
The currently formula is:
=SUMPRODUCT(($B$1:$B$8)($B$1:$B$10=A2),($D$1:$D$8)($B$1:$B$8=A2))
Where A2 is a reference to the FUND.
This is working for January. However, When I do this for February I am getting #Value! for all 3 funds. I think it is because of the blanks and tried <>"" but just got strange numbers.
The results should be
FUND Jan Feb
1 15100 4400
2 16500 3000
3 -5220 5080
Any help in solving this problem is appreciated?

Like this, modify ranges as needed. Note that repeating the $B$1:$B$8=A2 is redundant* — you only need one instance.
=SUMPRODUCT(($A$2:$A$9=$G2)*B$2:B$9*D$2:D$9)
*I'm assuming the 10 in $B$1:$B$10=A2 is a typo and should be 8.

Related

Returning total sum of value for each month. VBA

I need to produce a total value for each month of the year from a generated report. Data is split into colunms one with a value you the other with a date.
I need to return a total for each month.
Data is output as such:
100 21/01/2019
200 21/06/2019
150 01/01/2019
300 14/09/2019
8 08/05/2019
I need it to return as
1 2 3 4 5 6 7 8 9 10 11 12
250 0 0 0 8 200 0 0 300 0 0 0
With a further column for the following year. The original data and dates can be removed as this can be reproduced when running the next report.
You could try the below:
Add a helper column next to you date to get the month of the date:
=MONTH(B3)
and use:
=SUMPRODUCT(($C$3:$C$7=F2)*($A$3:$A$7))
Results:

How to multiply each row and then sum it with the product in the next row etc

I am trying to calculate total for each month based on Score and Number of occuruencies each month:
Category# Score Jan-18 Feb-18 Mar-18 Apr-18
category1 10 1 5 1 5
category2 8 2 4 2 4
category3 7 3 3 3 3
category4 6 4 0 4 0
category5 5 0 1 0 1
TOTAL 71 108 71 108
In the essence, for January I could type the following formula:
=($B$2*C2)+($B$3*C3)+($B$4*C4)+($B$5*C5)+($B$6*C6)
But it is very clumsy, so I am wondering if I could something more elegant and clean
that is what SUMPRODUCT is for
=SUMPRODUCT($B$2:$B$6,C2:C6)
Use SUMPRODUCT. It's exactly what you need:
SUMPRODUCT function
I replied your data:
The formula I have used is:
=SUMPRODUCT($B$4:$B$8;C4:C8)
After applying to first column (Jan-18), just drag it to the right, and it should return the right values, as you can see in the image.
Hope this helps!

Using Excel to allocate values based off their rank while remaining within constraints

I am trying to create a resource calculator that can tell me how many people i need to put on each section depending on the current work waiting and work coming in. Prioritizing sections which have the most work waiting first.
Upper Limit Allocation Prod Ranking
12 [to calc] 28% 1
15 18% 2
5 17% 3
4 8% 4
2 6% 5
3 .2% 6
4 .2% 6
Similar to the other question I have a constraint that i only have so much to allocate. For this example we will use 38 as the amount that is to be allocated.
I have used the formula from the other answer:
=MIN(A2,$E$1-SUMIF($D$2:$D$8,"<"&D2,$B$2:$B$8))
Where E1 contains the total to be allocated.
I have two issues with this formula:
1)The issue that I am having is that I require a minimum value of atleast 1 person in each of these sections.
I have tried using a max function to simply set this value, however this leads to the resources allocated going over the total amount.
What equation would I need to use to make it account for both the total available to allocate, the minimum requirement for each fund and the maximum limit for each fund.
2) It only returns solid integers, would there be a way to retreive more precise results, maybe by changing it to a % distribution?
UL Alloc Rank Capacity Lower Limit
2 1 15 93 1
3 1 15
4 1 15
6 6 8
1 1 15
2 1 15
4 4 9
2 2 7
4 4 4
15 15 2
12 12 10
12 12 1
1 1 11
13 13 5
6 6 6
5 1 15
5 5 3
1 1 14
2 2 13
3 3 12
3 1 15
Reference: Using the Excel's Rank() function to calculate allocations based on ranking and constraints
Simply subtract the 100 on all sides and add them separately:
=MIN(A2-100,($E$1-100*COUNTA($A$2:$A$8))-(SUMIF($D$2:$D$8,"<"&D2,$B$2:$B$8)-COUNTIF($D$2:$D$8,"<"&D2)*100))+100
What is returned depends on your entries in Column A and in E1. You can change Column A based on a percentage distribution and the formula will return the corresponding values.
Edit:
If you set your lower threshold into F2, your Constraint into E2, using this formula
=MIN(A2-$F$2,($E$2-$F$2*COUNTA($A$2:$A$8))-(SUMIF($D$2:$D$8,"<"&D2,$B$2:$B$8)-COUNTIF($D$2:$D$8,"<"&D2)*$F$2))+$F$2
the result looks like this:

Excel - running % of running total in pivot table

I have a table like:
periodo quintil pos
201611 1 10
201611 2 20
201611 3 30
201611 4 40
201611 5 50
201612 1 9
201612 2 19
201612 3 29
201612 4 39
201612 5 49
I need to create a pivot table like:
periodo quintil running_pos running_%
201611
1 10 7%
2 30 20%
3 60 40%
4 100 67%
5 150 100%
201612
1 9 6%
2 28 19%
3 57 39%
4 96 66%
5 145 100%
Since the running total is not a new field, but a way to show an older field (pos- show as total in quintil), the problem arises when I try to create the running % of the running total.
How can I introduce also this field (running % of running total)?
In spanish there's nothing with a name like running totals translation....
To display what you want in a Pivot Table
- Drag pos to the values area three times
- For the first, use the SUM
- For the second, use the "show as running total"
- For the third, use the "show as % running total"
Here are the results with minimal formatting
Here are the value settings for the third column:

Dynamically determining range to apply formula/function in EXCEL

I need to determine the range to apply the Frequency function. Here's what the problem is. On the given sheet, I have subtotals for my data and there is a column which has "Stop" Values.
The data would look something like:
Route1
Order# Stop# Qty
001016 1 5
008912 1 5
062232 2 6
062232 3 2
069930 4 1
1000 4 3
1001 4 4
1001 5 8
1003 8 1
Route 1 Subtotal 6 35
Route2
Order# Stop# Qty
10065 1 5
10076 1 5
10077 2 6
10079 3 2
10087 4 1
10098 4 3
10109 4 4
10171 5 8
10175 8 1
Route 2 Subtotal 6 35
How do I write VBA code for calculating the distinct stop values. I need the distinct count of the stop#. Hence in the example above you can see that the total stops are 6 because 1 stop can have multiple orders and 1 route can have multiple orders/stop. Hope I am making sense here. Let me know how I would write my VBA code for this. Thanks for your help.
For the Stop Subtotal unique count, try this formula (adjust ranges as required):
=COUNT(1/FREQUENCY(B2:B10,B2:B10))

Resources