I tried to summarize the idea of my question in the title, but it sounds a lot more complicated than it really is...
For anyone that doesn't know, Bloomberg is a data service provider where you can extract prices for various financial assets (and other things) into MS Excel. The format is quite typical: data is usually arranged in a time-series with dates progressing down rows and various financial products progressing across the columns.
Example: Historical prices for the S&P500 and DAX will appear in columns B and C,
respectively. The date for each price will appear in column A.
A B C D
DATE S&P500 DAX 'Formula'
02-Jan-14 1,462 7,778 = B * C
03-Jan-14 1,459 7,756 = B * C
04-Jan-14 1,466 7,776 = B * C
As time passes, the list gets longer with new prices, in this case the next price
for 05-Jan-14 would appear (actually the 7th is a Monday).
The problem arises when I have an Excel formula in column D that refers to either columns A, B, or C. As the days progress and the list of prices/dates grows longer (i.e. more rows), the formula in column D doesn't grow with this growing data set.
Is there a way in which MS Excel 2010 recognizes a dynamically sized data set from Bloomberg and automatically propagates referring formulas in adjacent columns downward (without using VBA)?
I can think of two possible ways that you could approach this. First, you could write your formula in a way that won't return anything if there is no date from the Bloomberg call in that row. For example, in your example your formula could be
=IF(A3="","",B3*C3)
You could then paste this down much further than your data will go. Even if the B3*C3 piece of the formula is costly, I don't believe it will slow your sheet down much as excel shouldn't even try to evaluate that piece of the formula unless there is a date in that row.
The other option would be to use VBA. You can take a look here for a relatively simple example.
Related
I am stuck trying to count the number of rows that meet a certain criteria. I have a large database in excel. Now on column A and B, I have a lot of text in cell, but I want to count every row if cell A or B meets my criteria.
Let's say column A has some notes from the morning and column B from the afternoon, and every rows represents a day. Now, let's say I want to count how many days I have mentioned "shopping", morning or evening. I would need a function like this:
// COUNTIF_OR(<range_1>,<criteria_1>,<range_2>,<criteria_2>)
COUNTIF_OR(A1:A100;"*shopping*";B1:B100;"*shopping*")
Most solution I could find on the internet counts the rows if A AND B meet the criteria, instead of A OR B.
Please, help me!
Since your two columns are contiguous, you could use:
=SUMPRODUCT(N(MMULT(N(ISNUMBER(SEARCH("shopping",A1:B100))),{1;1})>0))
though I would be tempted by:
=SUM(COUNTIFS(A:A,{"=";"<>";"="}&"*shopping*",B:B,{"<>";"=";"="}&"*shopping*"))
which, notwithstanding its rather obtuse nature and the fact that it is not readily extendible to more than two columns, does nevertheless mean that you can continue to employ COUNTIFS and so benefit from referencing entire columns (A:A, B:B) with virtually no detriment to calculation performance (which cannot be said for the SUMPRODUCT/MMULT set-up).
Morning all my first post here, need some advice on a complex formula. I do not code - no VBA, no macros. Working in a massive hospital company and focused on process improvement. as such lots of compliance concerns and will have to dummy up data if example sheets are needed.
The short version - i have a weekly project that runs on a template I built. It works well currently. I have a monthly report that this weekly project compares to and pulls data from. The monthly report is incredibly heavy - not less than 1000 lines of data, and I index one of two data points from it, based on a match of one of eight columns. I've gotten an index/iferror/match formula working to capture half of the data. However i am stumbling on what should in theor be the easiest part.
The desired outcome is on the weekly tab in column D - the formula needs to evaluate first whether the value in WEEKLY column C "type" is "I" or "O". Then based on that result, the index/iferror/match which change the index from MONTHLY column U to MONTHLY column V.
Currently the formula i have works as an index on MONTHLY column U, and properly evaluates whether WEEKLY A, or B, or C, or D, or E or F or G or H is matched. When I wrap the whole thing in an "IF([#[Type]]=I,INDEX...) then it immediately errors. Any advice is appreciated. Screenshot of "WEEKLY" and "MONTHLY" below with a copy of the current half-effective formula in the weekly column D slot for reference.
enter image description here
I need to create a module that will count the amount of values in specified date ranges, with other criteria.
For example, I have a list of products (Products A, B , C, D) in column C, and their sale date in column G.
I need to count all of product A sold before 1/1/1998. I then need to calculate product A sold between 1/1/1998 and 1/1/2005 etc.
I need to be able to run this for all the types of products, and group products together.
E.g. count all of product A & B sold before 1/1/1998.
This has to be done for a new workbook on a weekly basis so ideally needs to be able to be run for a new workbook each week. The tab names always remain the same.
Any help on how to get started would be appreciated
This answer will assume that your dates are entered as excel dates in column G and not a text. You can test this by using the formula =ISNUMBER(G3) where G3 is one of your dates. If it returns true, then your date is properly stored for use by excel formulas and this answer.
=SUMPRODUCT((($C$1:$C$100="A")+($C$1:$C$100="B"))*($G$1:$G$100<Date(1998,1,1))
That is how to hard code it. Personally I would build a table. Each row of the table would be a product you are interested in knowing the count for and a sum of the count would give you combined totals. Repeat the table if you need multiple combinations.
In the following example a single product was counted and then the total for all products listed was the total. The formula for the example in L3 and copied down for each product was:
=SUMPRODUCT(($C$2:$C$9=$J4)*($G$2:$G$9<K4))
The total at the bottom of the table was a simple SUM formula. Because SUMPRODUCT performs array like operations, avoid using full column references and try to restrict it to the data that needs to be checked. Otherwise you may notice a slow down in your system as multiple excess calculations are being perfomed.
I am trying to assemble a index/match combination and am having trouble figuring out how to make it work. I have experience with a lot of the formula types in excel, but unfortunately I am pretty ignorant when it comes to these functions.
I will explain what I am trying to do first, but I have attached 3 images at the end that will probably make things more clear.
In order to identify the specific values I want, I am having to use helper cells. These helper cells are denoted with the (helper) tag in the pictures. These cells go through and grab the adjusted closing price of the stock (column A) at the beginning (column C) and the end (Column D) of a dynamically calculated period.
I would like to consolidate these values into numerical order in columns F and G. The thought is that the first non zero number in C/D is belongs to the first predefined period and should go into columns F/G beside the #1 (column E). This gets carried on through all of the periods (ex: 2nd non zero goes beside the number 2, third nonzero number goes beside the number 3 etc.)
This is just an example of one stock. I need the function or formula to be dynamic enough to work on a wide variety of distributions. Sometimes there are up to 100 dynamically calculated periods within the stock analysis.
Below are the images that should provide more clarity
Image 1 is an example of what the data looks like
Image 2 is a crudely drawn example of how I would like the data to move
Image 3 is the desired result
Image 1
Image 2
Image 3
Updated image for Scott Craner showing out of order results
Please let me know if I can clarify any confusion.
If you just need to return the first value of each period (column C) and the last value of each period (column D), you could use index match and lookup to do this without even using helper columns.
Try this in cell F2
=INDEX(A2:A50,MATCH(E2,B2:B50,0))
And this in cell G2
=LOOKUP(E2,B2:B50,A2:A50)
Depending on much variance is in your overall number of rows, you could use indirect references in the formulas to dynamically update the ranges.
Example:
=INDEX(A2:INDIRECT("A"&COUNTA(A:A)),MATCH(E2,B2:INDIRECT("B"&COUNTA(A:A)),0))
You will need to open macro. Then do the following in recorded macro.
+ Filter only non-null value in C/D
+ Select whole column in C/D then copy the whole column
+ Turn off Filter
+ Paste the whole C/D in F/G
+ Stop macro
Gook Luck
Put this formula if F2:
=INDEX(INDEX(C:C,MATCH($E2,$B:$B,0)):INDEX(C:C,MATCH($E2,$B:$B,0)+COUNTIF($B:$B,$E2)-1),MATCH(1E+99,INDEX(C:C,MATCH($E2,$B:$B,0)):INDEX(C:C,MATCH($E2,$B:$B,0)+COUNTIF($B:$B,$E2)-1)))
Copy over one column and down the list.
I'm performing array calculations that are taking a long time to complete. I'd like to optimize my formulas some more. All of the formulas are of the same nature - they perform some high-level function (Average, Slope, Min, Max) across a column of values. However, not all cells in a column are included in the array. I use multiple IF criteria to choose which cells get included. All comparisons are made to the current row. Here's an example of the data:
A B C D E
1 Company Generation Date Value ToCalculate
2 Abc 1 1/1/2010 5.6
3 ... ... ... ... ...
E would look something like this
{=Average(If(A2=A2:A1000, If(B2=B2:B1000, If(C2 > C2:C1000, D2:D1000))))}
So once E2 is calculated then I have to autofill down column E. Column F, G, H, ... Uses the same approach, either selects different values to operate on or a different function to perform. My dataset is quite large, and with only a few of these the spreadsheet is taking an hour plus to compute. Every so often I'll add a fourth criteria, all other criteria being the same.
Is there an efficiency? Some thoughts:
Can I use a single array per column instead of thousands per column?
Can I condense the first three criteria so that the output is row numbers? Perhaps then subsequent formulas won't have to search for multiple criteria but can just perform the function?
or somehow build the crtieria up? So a new column returns all rows where the company is the same. another column returns all rows from the first column where generation is the same...and so on...
For the Average you can do without arrays:
=AVERAGEIFS(D2:D$1000,A2:A$1000,A2,B2:B$1000,B2,C2:C$1000,"<="&C2)
As there is also a COUNTIFS and a SUMIFS, I think your slopes could be calculated the same way.
For the rest of the functions (max, min, etc), we should analyze case by case.
I did a slight performance test, and this is apparently better, but of course my datasets are just mocked.
HTH!
Note: Excel 2007 and up only!
Edit - Answering your comment.
Without knowing the dimensions of the problem is difficult to give advice, but I'll risk one anyway:
You could write a VBA function that:
1) Generates a new sheet for each company-generation pair
2) Sorts the data in those sheets by date
3) Adds the formulas to those sheets (no conditionals needed in this context)
4) Recalculates and Gets the results from those formulas and populates the original sheet
5) Deletes the auxiliary sheets
To capture the rows and re-use try this approach:
Sort the data by Company & Generation.
Make a unique list of Companies & generations (use Advanced Filter, Unique Only, Copy)
For each Company generation pair in the list build 2 columns of formulae. First column gives the count of rows in the data for this pair (use COUNTIFS), second column gives the first row in the data for this pair (=first row for previous pair+count of rows for previous pair). Then you can use a function like OFFSET to return only the rows of data for the Company-Generation pair and embed this inside the final function/array formula (AVERAGEIFS etc) You could extend this sort and count approach to include dates if you wanted. There is a drawback that if the list of cities and generations change you have to change the list of uniques and associated formulas. There are examples of this approach on my website athttp://www.decisionmodels.com/optspeedk.htmhttp://www.decisionmodels.com/optspeedj.htm