Dynamically construct range to use in XIRR formula - excel

I have a sheet in this form:
Fund | Date | Amount
A | 10-Jan-05 | -5000
A | 10-Feb-05 | -5000
A | 08-Oct-13 | 12500
B | 10-Sep-05 | -5000
B | 10-Oct-05 | -5000
B | 10-Nov-05 | -5000
B | 08-Oct-13 | 22500
I'm looking for an output column that provides the XIRR for each fund. The XIRR function takes values and dates as ranges. I need a way to dynamically construct the range using the fund name as a search criteria.
Fund | XIRR
A | ...
B | ...
I could manually specify the range for each fund after sorting it by name, but its not a scalable solution.

You can use OFFSET to get the correct ranges, e.g. this formula
=XIRR(OFFSET(C$2,MATCH(A11,A$2:A$8,0)-1,0,COUNTIF(A$2:A$8,A11)),OFFSET(B$2,MATCH(A11,A$2:A$8,0)-1,0,COUNTIF(A$2:A$8,A11)))
see screenshot

Related

Excel formul to count Table Range using month from date text

I have an excel workbook where I am trying to count the number of apples in a named table. The workbook has multle sheets each named Jan, Feb, Mar, etc. with a corresponding table range of the same name.
My main worksheet has a list of months as columns and fruit as rows, I want to use a countif or suitable function to count the number of each fruit per month using the column heading as the worksheet portion of the formula.
This is what I have tried, this works, but has to be manually coded for each month, i would prefer it be more dynamic.
=COUNTIF(JAN[Labels],$A2)
Note: A2 contains the word apple
I have tried to get the month from the column date but it doesnt work
=COUNTIF(TEXT(E25,"mmm")[Labels],$A2)
This is roughly what the "master" table should look like (for clarity)
| | Jan-20 | Feb-20 | Mar-20 | .... |
| Apple | 4 | 3 | 5 | ... |
| Pear | 5 | 4 | 9 | ... |
EDIT:
Just to assist with anyone trying to help, this is roughly what a table on another sheet will look like:
| invoice | labels|
| 12535 | Apple |
| 12536 | Pear |
| 12537 | Apple |
This table would be a named table of Jan or Feb, etc.
Please try this:-
=COUNTIF(INDIRECT(TEXT(G2,"mmm")),"A")
G2 contains a proper date.
Here is a variation of the above where column 2 of the table is specified as the range to count in.
=COUNTIF(INDEX(INDIRECT(TEXT(G2,"mmm")),0,2),"B")
If you must use column captions to identify the column I would suggest MATCH to find it.
OK, so I found an answer, combining the above answer by Variatus with an additional new row.
| A | B | C | D |
1| | Jan-20 | Feb-20 | Mar-20 |
2| |JAN[Labels]|FEB[Labels]|MAR[Labels]| <- =UPPER(TEXT(B1,"MMM"))&"[Labels]"
3|Apple | 5 | 7 | 3 | <- =COUNTIF(INDIRECT(B$2),$A3)
4|Pear | 7 | 2 | 9 |
5|Orange| 1 | 3 | 3 |
So formula in B2 makes an uppercase text value of the month from B1 plus the column name Labels.
The formula in B3 (and down) counts the number of instances of the fruit from the named table & column shown in B2.

Rank with condition

I'm searching for a formula which could rank a value from a subset of a range.
Let's say Col.A is Departement and Col.B is value.
I want a formula which can rank the value from all the other value of this departement.
I have tried things
{=rank(value,if(myrange=condition,myrange),0)}
Does not work.
I have managed to do the oposite - retrieving the value of a certain rank with :
{=small(if(myrange=condition,myrange),rank i want)}
I don't understand why my first formula fail.
Excpected result would be the rank of the value from it's subset of value which is all cells where the condition is true.
For such scenarios (ranking a subset of data), I find using SUMPRODUCT much easier:
=SUMPRODUCT(($A$2:$A$12=A2)*(B2<$B$2:$B$12))+1
This is for descending order. Result:
Although Excel has a RANK function, there is no RANKIF function to
perform a conditional rank. However, you can easily create a
conditional RANK with the COUNTIFS function. Exceljet
Some sample data:
| Dep | Val |
|-----|-----|
| A | 5 |
| A | 3 |
| A | 6 |
| A | 6 |
| B | 3 |
| B | 8 |
| B | 2 |
| C | 9 |
| C | 5 |
| C | 7 |
Let's put the COUNTIFS in there:
Formula in C2 for descending:
=COUNTIFS($A$2:$A$11,A2,$B$2:$B$11,">"&B2)+1
Formula in D2 for ascending:
=COUNTIFS($A$2:$A$11,A2,$B$2:$B$11,"<"&B2)+1
Drag both down....

Return status of customer from most recent contact date

I have a list of customers, and a spreadsheet that tracks each encounter with them. A sample table looks like this:
Workbook 1: Table of customers
+------------+----------------+---------------------+
| Name | Current Status | Last Date Contacted |
+------------+----------------+---------------------+
| Customer A | Active | 3/1/2018 |
| Customer B | Inactive | 3/2/2018 |
| Customer C | Closed | 3/3/2018 |
+------------+----------------+---------------------+
Workbook 2: List of encounters
+------------+------------+----------+
| Name | Status | Date |
+------------+------------+----------+
| Customer A | New | 1/1/2018 |
| Customer A | Active | 2/1/2018 |
| Customer A | Active | 3/1/2018 |
| Customer B | New | 1/2/2018 |
| Customer B | Active | 2/2/2018 |
| Customer B | Disengaged | 3/2/2018 |
| Customer C | New | 1/3/2018 |
| Customer C | Active | 2/3/2018 |
| Customer C | Closed | 3/3/2018 |
+------------+------------+----------+
I have the following formula to return the last date contacted:
{=MAX(IF(Encounters[Name] = [#[Last Then First Name]], Encounters[Date])))}
I would like a formula that looks for the most recent date for each Customer, and return the status associated with that date. Is there a way to do this with formulas. Keep in mind that the formula would need to continue to work even if the worksheet were to be sorted. Thanks!
Assuming your table of customers is in Sheet1 (columns A to C) and your list of encounters is in Sheet2 (column A to C), and you already have your latest date of encounter per customer in column C of Sheet1, then you can enter the following formula in Sheet 1 cell B2 (then drag down to your last customer):
=INDEX(Sheet2!$B:$B,MATCH(1,(Sheet1!$A2=Sheet2!$A:$A)*(Sheet1!$C2=Sheet2!$C:$C),0))
This allows you to capture the latest status per customer. The formula would however be pretty taxing on the efficiency of Excel's calculation, so you can change the reference ranges to your structured table references. Please don't forget to return the formula using CONTROL+SHIFT+ENTER.
Use the following standard (non-CSE) formulas to gain the latest date and accompanying status per the supplied image.
'G2
=INDEX(B:B, AGGREGATE(15, 7, ROW(A:A)/((A$1:A$10=F2)*(C$1:C$10=H2)), 1))
'H2
=MAX(INDEX(C$2:C$10-(A$2:A$10<>F2)*1E+99, , ))

Excel function, exclude dates in chart data source

I am forming a chart from sheet A. Sheet B contains all my data.
I want to exclude a specified date(s).
Sample data:
+---+----------+--------------+--------------+-------------+-------------+-------------+
| | A | B | C | D | E | F |
+---+----------+--------------+--------------+-------------+-------------+-------------+
| 1 | Date | 29/03/2017 | 30/03/2017 | 31/03/2017 | 03/04/2017 | 04/04/2017 |
| 2 | Number 1 | -594590.4649 | -636666.4504 | 795637.1614 | 842563.4322 | 496463.9301 |
| 3 | Number 2 | 2189587.44 | 1301681.418 | 2080839.353 | 1945335.214 | 2421728.123 |
+---+----------+--------------+--------------+-------------+-------------+-------------+
The final output would be me excluding 30/03/2017 , and keeping the rest in my data selected for my chart.
the issue is that I want to maybe exclude a date in the middle of my selected range. But since this may be a hassle to input a long formula each time into my data selected. I would like to see if there is any formula/function to eliminate a specified date/column. Perhaps manually enter the column you want to exclude in a formula.
My current range is something like =Graph!$AB$5:$KA$7 But is there a function to exclude one of these columns?
I can manually select which dates with Ctrl but seems tedious.

Excel: How to sum a column to date from a specified date where date ranges are involved

I'm sure i have seen this done with a short formula but i am struggling to remember how to do it.
I am trying to find where a date falls in an interval and sum another column, from that point in the interval, to the end of all specified date intervals.
So, in the image below the intervals are in columns D and E and the date to find is in cell F1 i.e. 12/12/2016.
I want to find where 12/12/2016 falls within the ranges and sum column F accordingly i.e. 12/12/2016 - 13/12/2016 (2 days) and then all intervals after will be 2 + 6+2+1+3 = 14. I am returning this result in cell J14.
I have used the idea of histograms to calculate this currently, but the formula is large and unwieldy, and i just know i have seen a similar question, somewhere on SO but can't find it, that does this with SUMPRODUCT and OFFSET only. I guess FREQUENCY could also be used.
So what i have currently is:
=SUMPRODUCT(OFFSET(F6,MATCH(TRUE,OFFSET(E6,0,0,COUNT(E6:E1048576),)>F1,0)-1,0,COUNTA(F6:F1048576),))-(F1-OFFSET(D6,MATCH(TRUE,OFFSET(E6,0,0,COUNT(E6:E1048576),)>F1,0)-1,,,))
Where, if i broke it down into stages, i find which bucket (range) has the target value:
={MATCH(TRUE,OFFSET(E6,0,0,COUNT(E6:E1048576),)>F1,0)}
I calculate the distance into the range with:
=F1-OFFSET(D6,H13-1,,,)
And i sum from this point until the end of the range with:
=SUMPRODUCT(OFFSET(F6,H13-1,0,COUNTA(F6:F1048576),))-I13
So, can anyone help me with a shorter more efficient formula please?
Data:
| Start of measurement | 12/12/2016 | |
|----------------------|------------|----------------|
| | | |
| | | |
| | | |
| From | To | Number of days |
| 13/11/2016 | 17/11/2016 | 5 |
| 10/12/2016 | 13/12/2016 | 4 |
| 03/02/2017 | 08/02/2017 | 6 |
| 06/12/2017 | 07/12/2017 | 2 |
| 09/12/2017 | 09/12/2017 | 1 |
| 12/12/2017 | 14/12/2017 | 3 |
This should work for you:
=SUMIF(E6:E11,">="&F1,F6:F11)-F1+INDEX(D6:D11,MATCH(F1,D6:D11))
How about this?
=SUMIFS(F6:F11,D6:D11,">="&F1)+MINIFS(E6:E11,E6:E11,">="&F1)-F1+1
The SUMIFS() gives the 6+2+1+3 part and the MINIFS() - F1 + 1 gives the 2 part.
Note that the ___IFS() functions are more recent and not available in older versions of Excel.

Resources