Sum up cells based on conditions - excel

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.

Related

How do I recieve the number of cells based off of three columns in Excel?

I'm not too sure how to word this problem so, I apologize for the vagueness. Here is what I am trying to do though:
I have a large Excel table with a ton of values, I however, only care about 3 columns. The three columns I have are "Project Name", "Active/Planned", and "Week of Month". Here is an example of some values I would have:
Project Name
Active/Planned
Week of Month
StoreProj
Active
2021-07 Jul-Wk1
SecProj
Planned
2021-07 Jul-Wk2
StoreProj
Active
2021-07 Jul-Wk1
Now, I have used a formula to get the number of projects based on a specific week month and avoiding duplicate values for the project name. The code I used returns an integer of the number of projects. Here is what I used:
=IFERROR(ROWS(UNIQUE(FILTER(Table[Project Name],Table[Week of Month]=2021-07 Jul-Wk1))), 0)
This works as intended. Now the issue I am running into is that I need to filter through these rows as I did previously, but now I need to include the "Active/Planned" column. So, I want to be able to see how many projects I have based off of the week of the month and return a number of projects (excluding duplicate names), but be able to filter through that integer output based off of the active/planned projects. So in a perfect scenario I can choose the week of month and if the project is "Active" or "Planned" and see the amount of projects I have.
This might be an easy fix so I apologize, I am just stumped, any help would be greatly appreciated. Thanks!
Work through that step by step, you've got the FILTER function which is giving data to the UNIQUE function, to the ROWS function, and then your IFERROR. However, the data about whether each line/row is 'Active' or 'planned' isn't passed out beyond the FILTER function, so can't be used by anything further on in the above sequence.
Boring theoretical advice out the way, try this;
=COUNT(IF(UNIQUE(FILTER( Table[[Project Name]:[Active/Planned]], Table[Week of Month] = "2021-07 Jul-wk1"))= "Active", 1))
Explanation:
FILTER(...) outputs records with the relevant date filter, however it outputs Table[[Project Name]:[Active/Planned]] - both columns, to ensure all relevant data is there.
UNIQUE(...) Then narrows that down to unique values, although by this stage I'm not 100% sure you need this.
IF(... = "Active", 1) then replaces the 'Active' outputs with 1s
COUNT() returns the number of cells in the above that contain a number (the 1s from the IF())
Yes, you can't use COUNTIF on arrays (and all except that last bullet point above are outputting arrays not single values) - and no, I didn't know that before attempting to answer this question, found it over at a different question!

Index Match Match query Excel 2013

Good day.
I am having some difficulties inserting an Index Match Match formula into Excel 2013, and I can't for the life of me work out where I have gone wrong.
I have a data table (as seen in the screenshot). On the left hand column I have a list of sites; across the top I have a list of weeks, with the table filled with sale predictions. I basically want to bring through the sales predictions For a specific named site and week in rows 22 and 23, and the formula I have is:
=IF(ISERROR(INDEX(B2:AO20,MATCH(B22,B3:B20,0),
MATCH(B23,C2:AO2,0))),0,INDEX(B2:AO20,MATCH(B22,B3:B20,0),MATCH(B23,C2:AO2,0)))
All the is being is returned is a 0 value; without the error handling, all it returns is a #N/A!.
Is anyone able to advise me or point me in the right direction at all please?
Screenshot is hopefully below
Screenshot
Perhaps protect this with an ISERROR statement, but otherwise this should work:
=vlookup(b22,$b$2:$ao$20,match(b23,$b$2:$ao$2),false)
Although instead of protection (or as well as) I'd make the site and week cells into validated lists

Excel 2010 index match - multiple criteria

I am new to using index/match, and I'm facing some trouble. I have two worksheets, one with table act and the other with table wa. act contains 7,199 rows; wa has 25,099 rows.
I am trying to match order number and date in order to pull a document number from wa onto act. The order numbers will be an exact match, but the date on act is slightly less than the date on wa.
My formula is:
=INDEX(WA[BillingDocumentNumber],(MATCH([#[Customer PO Number]],WA[PO],0)+MATCH([#[GL Posting Date]],WA[CostPostedOn],-1)))
Depending on how I sort the wa data, I have gotten the following results:
494 document numbers returned (sometimes correct; sometimes pulling from the cell in wa directly beneath the cell that should be returned) with the rest #N/A;
approximately 1400 document numbers (all incorrect, I think) with the remaining being either #N/A or #REF
Can anyone help me? I have no practical knowledge of VBA, but I am the resident Excel "expert" (seems funny to me) in my company, so I am the person who is faced with the task of solving this problem... I have combed the existing forums, but I haven't found any that seem to provide a (non-VBA) solution for my problem. Any ideas would be greatly appreciated!
Thank you for your time.
Here is my untested proposed solution:
{=CONCATENATE(IFERROR(IF(AND(WA[PO]=#[Customer PO Number],WA[CostPostedOn]>#[GL Posting Date]),WA[BillingDocumentNumber],""),""))}
Entered as an Array Formula using CTRL + SHIFT + ENTER.
This will return in one text string all results that match the PO number and in which the act date is older than the wa date. You can modify your second and add a third conditional in the AND to create date ranges (ie WA[CostPostedOn]>=#[GL Posting Date]+7 or WA[CostPostedOn]<=#[GL Posting Date]-7).
As you are using arrays though there might be some performance issues when you scale this to 7,000+ formulas. Sadly you can't do a VLOOKUP with 2 conditionals.
Hope this helps. Cheers,

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.

MS Excel IF statement confusion

I'm trying to make a spreadsheet for some calendars that I'm selling. I have a pricing scheme which depends on how many calendars a customer buys. I want to be able to keep track of sales, but I don't want to have to input the price per unit for each sale. I set up an IF statement that seems to work except for the last variable. Here's a screenshot:
As you can see, it works all the way to the last one. After the number reaches 11, the price per unit should drop to 6, but it doesn't! I know it must be a simple fix, but I don't know much about IF statement, so I'm stuck. Please help!
If you set up your price table similar to my set-up below, you can use a VLOOKUP formula to make it more flexible.
The formula in H10 is:
=VLOOKUP(G10,$B$1:$C$5,2,TRUE)
Enter and drag down.
The benefit of this approach is that you can change the lower bound count on the left and you'll get an adjustment without having to update the formula. Try changing the 2 in Count to 3 and you'll see the adjustments right away.
An added benefit is you can add some more values to the table for further pricing brackets.
If you must use an IF statement, try:
=IF(G10=1,9,IF(G10<=5,8,IF(AND(G10>5, G10<11),7,IF(G10>=11,6,IF(G10="","")))))
The problem with yours is it will never read the if(G10>=11 part because it has already evaluated if(G10>5
If it should have no output when G10 is blank, use the following variant:
=IF(ISBLANK(G10),"",IF(G10=1,9,IF(G10<=5,8,IF(AND(G10>5, G10<11),7,IF(G10>=11,6,IF(G10="",""))))))
I agree with #Nanashi that putting the price thresholds in a separate table and using vlookup is a better solution. That would make it possible to change the price points without having to edit multiple formulae.
But to just get your formula working, try this: =if(g10="","",if(g10=1,9,if(g1<=6,8,if(g10<=10,7,6))))
Notice that:
You don't need (and probably don't want) quotes around your numeric
values
The order of tests is important. In your original, the test for g10>=11 is never reached because it is in the else part of the g10>5 function.
A properly constructed table of quantities and pricing coupled with a VLOOKUP formula would be the best way to go and eases future pricing changes. But for the sake of diversity, your straightforward pricing structure could also be handled by the following:
=(6+(G10<11)+(G10<6)+(G10<2))*(G10>0)
In the formula, "G10>5" should be "G10<=10". Otherwise, when it gets to 11, it still meets the G10>5 criteria.

Resources