Simplifiy and make an more efficient Excel Formula - excel

I have been continually adding in complexity to my formulas to accomodate the large amount of data. I have been trying to simplify this excel formula but cannot seem to find a way that works well. I would appreciate any advice!
{=IFERROR(IF(INDEX(FullFlow_2,SMALL(IF(FullFlow_2[SN]=[#SN],ROW(FullFlow_2[SN])-ROW(INDEX(FullFlow_2[SN],1,1))+1),COLUMN(M$2)-COLUMN($L$2)),4)="Complete",INDEX(FullFlow_2,SMALL(IF(FullFlow_2[SN]=[#SN],ROW(FullFlow_2[SN])-ROW(INDEX(FullFlow_2[SN],1,1))+1),COLUMN(M$2)-COLUMN($L$2)),2),IF(VLOOKUP([#SN],FullSNList_2,8,FALSE)="None",IF(ISNUMBER(MATCH(SUBSTITUTE(TRIM(M4),"`",""),TRIM($L4:L4),0)),INDEX(FullFlow_2,SMALL(IF(FullFlow_2[SN]=[#SN],ROW(FullFlow_2[SN])-ROW(INDEX(FullFlow_2[SN],1,1))+1),COLUMN(M$2)-COLUMN($L$2)),2)&"` ",INDEX(FullFlow_2,SMALL(IF(FullFlow_2[SN]=[#SN],ROW(FullFlow_2[SN])-ROW(INDEX(FullFlow_2[SN],1,1))+1),COLUMN(M$2)-COLUMN($L$2)),2)&" "),IF(OR(VLOOKUP([#SN],FullSNList_2,8,FALSE)="Dev",VLOOKUP([#SN],FullSNList_2,8,FALSE)="ECO",VLOOKUP([#SN],FullSNList_2,8,FALSE)="Rework"),IF(ISNUMBER(MATCH(SUBSTITUTE(TRIM(M4),"`",""),TRIM($L4:L4),0)),INDEX(FullFlow_2,SMALL(IF(FullFlow_2[SN]=[#SN],ROW(FullFlow_2[SN])-ROW(INDEX(FullFlow_2[SN],1,1))+1),COLUMN(M$2)-COLUMN($L$2)),2)&"` ",INDEX(FullFlow_2,SMALL(IF(FullFlow_2[SN]=[#SN],ROW(FullFlow_2[SN])-ROW(INDEX(FullFlow_2[SN],1,1))+1),COLUMN(M$2)-COLUMN($L$2)),2)&" "),IF(ISNUMBER(MATCH(SUBSTITUTE(TRIM(M4),"`",""),TRIM($L4:L4),0)),INDEX(FullFlow_2,SMALL(IF(FullFlow_2[SN]=[#SN],ROW(FullFlow_2[SN])-ROW(INDEX(FullFlow_2[SN],1,1))+1),COLUMN(M$2)-COLUMN($L$2)),2)&"` ",INDEX(FullFlow_2,SMALL(IF(FullFlow_2[SN]=[#SN],ROW(FullFlow_2[SN])-ROW(INDEX(FullFlow_2[SN],1,1))+1),COLUMN(M$2)-COLUMN($L$2)),2)&" ")))),"_")}
A little more info on the code. It is meant to scan a table and search for a step name (DOC###). Depending on other criteria's (if one column has none, rework, or broke, in it) spaces are added to the end to differentiate between them while being able to still be counted at a later step. Also, if a step is being done for the 2nd time, a period will be added afterwards.
I have been putting the formula in http://excelformulabeautifier.com/ to help read it a bit easier!
UPDATE: I have Modified the formula a bit and added explanations. The new code has replaced the old one in the body. I have attached pictures to show my explanation.
Formula Explanation PG 1
Formula Explanation PG 2
Example Data output
NOTES: In order for this to work for me, due to the circular references, I turned on Iterative Calculations and set the Max iterations to 2.

Removing the VLookups from the formula made the calculation time a lot shorter! Thank you all for your ideas! Any other suggestions are greatly appreciated!

Related

I've hit the character limit for a formula and when I try shortening it, I'm unable to

I have a pretty large data set I with adresses and postal codes, and I need to organize said data set by postal codes only, which resulted in a large number of variables.
The code goes like this (it continues for a long while, but in order to shorten it for easier access and reading:
=IF(ISNUMBER(SEARCH("NEPAL";F2));RIGHT(F2;5);IF(ISNUMBER(SEARCH("MALTA";F2));RIGHT(F2;5);IF(ISNUMBER(SEARCH("SWITZERLAND";F2));RIGHT(F2;5);IF(ISNUMBER(SEARCH("CHINA";F2));RIGHT(F2;5);IF(ISNUMBER(SEARCH("CHILE";F2));RIGHT(F2;5);"OTHER"))))))
I had to translate the formula since I'm using EXCEL in Portuguese.
TL'DR: My formula hit the character limit (it's a lot bigger than what's above) and I still have some variables I need to add to the formula (eg.):
IF(ISNUMBER(SEARCH("ANGOLA";F2));RIGHT(F2;6)
and other variables with the same functions.
If anyone could help me shorten the string, I would appreciate it!
Used the solution sugested by #Rory and it worked perfectly for what I wanted! Thank you all!

EXCEL - Circular Reference Error when Entering Data

I've got another one that is really kicking my butt.
I know why the error is occurring. I just don't know how to fix it. There are a lot of IF statements so I'm thinking maybe they are arranged in a way that is causing the error. I'm sure there is a much cleaner way to write them.
Whenever I try to input data into D7 or E7 I get the circular reference error.
These are my current formulas for all relevant cells:
F7: =IF(C7<0,"FAIL",IF(OR(ISBLANK(B7),ISBLANK(C7))," ",IF(ABS(F8)<=30,"PASS","FAIL")))
G7: =IF(D7<0,"FAIL",IF(OR(ISBLANK(B7),ISBLANK(D7))," ",IF(ABS(G8)<=30,"PASS","FAIL")))
H7: =IF(E7<0,"FAIL",IF(OR(ISBLANK(B7),ISBLANK(E7))," ",IF(ABS(H8)<=30,"PASS","FAIL")))
F8: =IF(B7<0,"",IF(C7<0,"",IF(D7<0,"",IF(E7<0,"",IF(G7="FAIL","",IF(H7="FAIL","",IF(ISBLANK(B7),IF(ISBLANK(C7),"","input Lw_Lw"),IF(ISBLANK(C7),"input Lw_Up",SUM(C7-B7)))))))))
G8: =IF(B7<0,"",IF(C7<0,"",IF(D7<0,"",IF(E7<0,"",IF(F7="FAIL","",IF(H7="FAIL","",IF(ISBLANK(B7),IF(ISBLANK(D7),"","input Lw_Lw"),IF(ISBLANK(D7),"input Up_Lw",SUM(D7-B7)))))))))
H8: =IF(B7<0,"",IF(C7<0,"",IF(D7<0,"",IF(E7<0,"",IF(G7="FAIL","",IF(F7="FAIL","",IF(ISBLANK(B7),IF(ISBLANK(E7),"","input Lw_Lw"),IF(ISBLANK(E7),"input Up_Up",SUM(E7-B7)))))))))
Snip of Excel table
Any help would be much appreciated!
I worked out the following two formulas for you. Please try them.
[F7] =IF(IFERROR(ABS(F8)<=30,FALSE),"PASS","FAIL")
[F8] ==IF(ISBLANK(C7),"input "&F$3,IF(OR(COUNT($B7:$E7)<4,COUNTIF($B7:$E7,"<0")>0),"",SUM(C7-$B7)))
Copy them from F7:F8 to G7:H8.
The basic principle I applied in order to avoid a circular reference is to do all testing in row 8 with the outcome that F8 will either hold a blank or a number. Therefore "Pass" or "Fail" in row 7 can be decided based on the number: If the number is within range it's a PASS, else it's failed. Note that Abs("") will cause an error. Therefore IFERROR(ABS(F8)<=30,FALSE) will return False in case F8 = "". Effectively, this is the reverse of what I wrote in my comment above.
I looked for shorter expressions for other tests as well. Count() will only count cells with numbers in them. Therefore I use this function instead of a series of ISBLANK() queries. Similarly for COUNTIF($B7:$E7,"<0").
I used mixed absolute and relative addressing to enable copying formulas to other columns and referred to the column captions in place of repeating the same texts in the formulas.
I didn't fully test my solution. However, with my above explanation as a guide you should be able to take possession and eliminate any errors I might have left behind.

Sum up cells based on conditions

I appreciate this could be treated as a simple question. I have been trying to figure out where I'm going wrong as I'm sure it is something simple ... from the Strategy Exposures tab you can see that his strategies are either macro or tactical I have a table (below) and have been asked to to sum up the required exposure for Macro and for Tactical depending on what is there. I want to create two separate cells. One which adds up 'Macro', and the other which adds up 'tactical'.
Strategy ExposureDescription ExposureRequired (USD)
EUR_MACRO DAX INDEX 2,000,000
EUR_MACRO FTSE INDEX 4,000,000
EUR_MACRO CAC40 INDEX 1,100,000
EUR_MACRO S&P INDEX 10,000,000
JPY_MACRO NKY INDEX 4,000,000
JPY_MACRO S&P INDEX 34,000,000
USD_TACTICAL S&P INDEX 4,000,000
JPY_TACTICAL NKY INDEX 6,000,000
JPY_MACRO S&P INDEX 3,000,000
Currently, I have tried variations of: =SUMIF(B$3:B$11,"*MACRO*",D$3:D$11)
however this formula keeps giving an output of 0. Table ranges from (diagonally) B2 - D11.
So it turns out after all of this, the SumIF function was working okay when we created a new workbook with brand new data. This prompted me to close down the current sheet which I was having formula issues with, disable the macros and re-try. It worked a charm. I have never experienced this before however as #brucewayne suggested, their must've been some conflict based on one of the macros. Unsure what yet, will look into this and see if I can figure it out. If I do will post more. Hope this helps someone.

How to optimize COUNTIFS with very large data

I would like to create a report that look like this picture below.
My data has around 500,000 cells (it will continue to grow larger)
Right now, I'm using countifs function from excel but it takes a very long time to calculate. (cannot turnoff automatic calculate)
The main value is collected as date and the range of date is about 3 years, so I have to put a lot of formula to cover all range of value.
result
The picture below is the datasource the top one cannot be changed. , while the bottom is the one I created by myself (can change). I use weeknum to change date to week number.
data
Are there any better formula or any ways to make this file faster? Every kinds of suggestions are welcome!
I was thinking about using Pivot Table, but I don't know how to make pivot table from this kind of datasource.
PS. VBA is the last option.
You can download example file here: https://www.mediafire.com/?t21s8ngn9mlme2d
I will post this answer with the disclaimer that it is entirely dependent on the size of the data set. That turning on and off the auto calculate is the best way, but your question doesn't let me do that, so keep reading.
Your question made me curious, so I gave it a try and timed it. I essentially set up two columns of over 100,000 rand numbers choosing from 1-1000 and then tried to do a countif on the two columns if they were equal. I made a macro that I can run that turns off the autocalculate, inserts the start time, calculates, and then inserts the finish time. I highlighted in yellow the time difference.
First I tried your way, two criteria, countifs:
Then I tried to combine (concatenate) the two columns to see if I could make it easier by only having one countif criteria and data set. It doesn't. see result below:
Finally, realizing what was going on. I decided to make the criteria only match the FIRST value in the number to look for. I was essentially reducing the number of characters to check per cell. This had a positive result. See below:
Therefore my suggestion is to limit the length of the words you are comparing in anyway possible. You are mostly looking at dates, so you might have to get creative, but this seems to be the best way possible without going to manual calculation.
I have worked with Excel sheets of a similar size. Especially if you are using the data on a regular basis, I would heartily recommend switching to a proper database SQL based, Access, or whatever fits your purpose. I does wonders for the speed and also you won't run into the size limits of Excel. :-)
You can import the data you have now fairly easy.
I am happy as a clam with my postgresql db.

I can't seem to solve an IF() false positive in Excel

Attached is a bowling sheet I have been working on to figure out my averages, and any "free game awards" I may get, as well as patches, etc...
https://dl.dropbox.com/u/3327208/excel/Bowling.xlsx
I am getting a false positive in column S.
Up till S12 the formula seems to work, in where there is a blank, and it shows me getting over 500.
The formula is:
=IF($E12>499,"X","")
Something simple and sweet or so I thought.
Now $E12 has this formula in it, which I don't see why it should affect it at all:
=IF(D12<>0,SUM($B12:$D12),"")
I tried using ISBLANK, but it seems to blow up in my face and not show anything. If someone can help me it would be greatly appreciated, thanks.
A simpler alternative
=IF(N($E12)>499,"X","")
Try this (in E9):
=IF(ISNUMBER(E9),IF($E9>499,"X",""),"")
This is likely a type comparison issue, so this only compares if the cell is actually a number.

Resources