Using a Dynamic Named Range inside a Sum Formula - excel

=SUM(IF(('Old Data'!$A$2:$A$10000=Tracking!A9)*('Old Data'!$B$2:$B$10000=$E$7)*('Old Data'!$D$2:$D$10000>$B$5)*('Old Data'!$D$2:$D$10000<$C$5),IF('Old Data'!$E$2:$E$10000-'Old Data'!$D$2:$D$10000<"4:00"+0,0.5,NETWORKDAYS('Old Data'!$D$2:$D$10000+0,'Old Data'!$E$2:$E$10000+0))))
is my current code. I created a defined name Total
Total = =COUNTA('Old Data'!$C:$C)
Everywhere that I have 10,000 I'd like to return the value of Total. I've tried simply replacing 10000 with Total, tryed using the + built in formula creator. I can't figure how to insert the value into my formula.
Any Ideas?

This seems like a formula question to me?
You can use INDIRECT See this example
If I have =Sum(A1:A10000) then in such a case I can use
=SUM(INDIRECT("A1:A"&total))
In my example total has been defined as =COUNTA('Old Data'!$A:$A)
Let me know if you still want a VBA solution.
SNAPSHOT
The best way to check it is to highlight the relevant section in the formula and click F9 to see how the values are calculated.

Related

Running total from a named array formula in Excel

I want to create a named dynamic array formula that will give me a spill showing a cumulative (running) total of another array. I want one that I can enter into any cell in my workbook and get the same results.
I have the following named formulas:
twelve: =ROW(OFFSET('CSM'!$A$1,0,0,12,1)) [EDIT: I realised later it's simpler just to define it as =SEQUENCE(12)] This generates an array of whole numbers from 1 to 12; I use it for a number of purposes, such as producing a list of months (=TEXT(DATE(2023,twelve,1),"mmm-yy").
FTE: ='CSM'!$B$3/12*(--(twelve=twelve)) This shows FTE's monthly salary (with cell B3 on sheet CSM providing the annual salary) over 12 months.
Now, if I enter =FTE on any cell, I'll get a 12-cell spill that shows the FTE's salary for each month. That's fine, but what I really need is a named formula that when it spills will show the FTE's cumulative salary (a running total).
I can do this with a formula that links to a specific cell...for example, if I want my display to start in row 2 I use:
=SUM((--(twelve<=ROW()-1))*FTE), and then drag the formula down the remaining 11 rows. But I have to adjust this formula if I use it somewhere else--for instance, if I want to start my spill on row 10 I have to write =SUM((--(twelve<=ROW()-9))*FTE). I really want a named formula that I can use anywhere on the sheet without modification, that will give me a spill showing cumulative monthly salary.
I see you can do this using the MMULT function when the data are all on a worksheet (see here), even when those data are a dynamic spilled array (see =MMULT(ROW(A1#)>=TRANSPOSE(ROW(A1#)),A1#), here). But when I use this approach on a named formula, I get a #VALUE error. I think the error actually comes from the ROW() function--it looks like I can use =ROWS(FTE) (returns 12), but not =ROW(FTE) (which returns the error).
So my question is: is there any way I can create a named formula that will give me a 12-month spill of FTE's cumulative salary by month? Maybe using SEQUENCE() or MMULT() or something else...(We haven't got Lambda yet, by the way.)
EDIT (in response to comments):
For example, if B3=$75,000, putting =FTE into any cell will produce this (spilling over into cells below):
$6,369.86
$5,753.42
$6,369.86
$6,164.38
$6,369.86
$6,164.38
$6,369.86
$6,369.86
$6,164.38
$6,369.86
$6,164.38
$6,369.86
What I want is a cumulative sum (running total) of the above; that is:
$6,369.86
$12,123.29
$18,493.15
$24,657.53
$31,027.40
$37,191.78
$43,561.64
$49,931.51
$56,095.89
$62,465.75
$68,630.14
$75,000.00
As I mentioned, we haven't got Lamda at this point, or any of those newer formulae.
OK, I've figured out a solution. For whatever reason, it seems you can't use ROW() with named dynamic array formulas, but it turns out I don't need to. I can simply use: =MMULT((--(twelve>=TRANSPOSE(twelve))),FTE) and I'll get the desired result (with 75000 being the value in B3):
6369.86
12123.29
18493.15
24657.53
31027.40
37191.78
43561.64
49931.51
56095.89
62465.75
68630.14
75000.00
I also found it useful to assign the above formula to a name, so I can conveniently enter it into any cell on the sheet and get the same output.
One more thing: I realised I can define the named formula twelve more simply by using =SEQUENCE(12), though the OFFSET approach still works. (Still getting used to some of there 'new' Excel formulas--not so new anymore, I guess.) I edited original question to mention this.

How do I use index match to find the first sale that a customer has made?

I have a table:
and I want to find the first order date for each customer.
For this, I have created a new column of customers and deleted the duplicates and tried using the function:
=MIN(IF($A$2:$A$74686=L2,$I2:$I74688))
But it doesn't seem to do what I want it to as the cells get larger.
I feel like I have to use an index match with the min function but I am unsure how to approach this.
As per my comment, it seems that in your current formula:
You are using ranges that are different in dimensions
You are using absolute references wrongly (in case you need to drag down)
So the correct formula would be:
=MIN(IF(A$2:A$74688=L2,I$2:I$74688))
Don't forget to enter through CtrlShiftEnter

How do I refine the results of an importXML function?

I'm making a spreadsheet to try and help track peoples heart of azeroth levels, and I've got my cell set as
=IMPORTXML("https://worldofwarcraft.com/en-gb/character/Zenedar/Father","//*[#class='GameIcon-level']")
however it seems to return the number 36 twice, once in the cell I want and another in the cell below, how do I refine this to a single cell of '36'
How about these modifications? In this modification, it adds the parent node.
Modified formula 1:
When you want to retrieve 1st value of 2 values, you can use this.
=IMPORTXML(A1,"//div[#class='CharacterProfile-item']//*[#class='GameIcon-level']")
Modified formula 2:
When you want to retrieve 2nd value of 2 values, you can use this.
=IMPORTXML(A1,"//div[#class='List-item']//*[#class='GameIcon-level']")
Note:
You can also use div[#class='GameIcon-level'] instead of *[#class='GameIcon-level'].

Using SUMIFS with multiple AND OR conditions

I would like to create a succinct Excel formula that SUMS a column based on a set of AND conditions, plus a set of OR conditions.
My Excel table contains the following data and I used defined names for the columns.
Quote_Value (Worksheet!$A:$A) holds an accounting value.
Days_To_Close (Worksheet!$B:$B) contains a formula that results in a number.
Salesman (Worksheet!$C:$C) contains text and is a name.
Quote_Month (Worksheet!$D:$D) contains a formula (=TEXT(Worksheet!$E:$E,"mmm-yy"))to convert a date/time number from another column into a text based month reference.
I want to SUM Quote_Value if Salesman equals JBloggs and Days_To_Close is equal to or less than 90 and Quote_Month is equal to one of the following (Oct-13, Nov-13, or Dec-13).
At the moment, I've got this to work but it includes a lot of repetition, which I don't think I need.
=SUM(SUMIFS(Quote_Value,Salesman,"=JBloggs",Days_To_Close,"<=90",Quote_Month,"=Oct-13")+SUMIFS(Quote_Value,Salesman,"=JBloggs",Days_To_Close,"<=90",Quote_Month,"=Nov-13")+SUMIFS(Quote_Value,Salesman,"=JBloggs",Days_To_Close,"<=90",Quote_Month,"=Dec-13"))
What I'd like to do is something more like the following but I can't work out the correct syntax:
=SUMIFS(Quote_Value,Salesman,"=JBloggs",Days_To_Close,"<=90",Quote_Month,OR(Quote_Month="Oct-13",Quote_Month="Nov-13",Quote_Month="Dec-13"))
That formula doesn't error, it just returns a 0 value. Yet if I manually examine the data, that's not correct. I even tried using TRIM(Quote_Month) to make sure that spaces hadn't crept into the data but the fact that my extended SUM formula works indicates that the data is OK and that it's a syntax issue. Can anybody steer me in the right direction?
You can use SUMIFS like this
=SUM(SUMIFS(Quote_Value,Salesman,"JBloggs",Days_To_Close,"<=90",Quote_Month,{"Oct-13","Nov-13","Dec-13"}))
The SUMIFS function will return an "array" of 3 values (one total each for "Oct-13", "Nov-13" and "Dec-13"), so you need SUM to sum that array and give you the final result.
Be careful with this syntax, you can only have at most two criteria within the formula with "OR" conditions...and if there are two then in one you must separate the criteria with commas, in the other with semi-colons.
If you need more you might use SUMPRODUCT with MATCH, e.g. in your case
=SUMPRODUCT(Quote_Value,(Salesman="JBloggs")*(Days_To_Close<=90)*ISNUMBER(MATCH(Quote_Month,{"Oct-13","Nov-13","Dec-13"},0)))
In that version you can add any number of "OR" criteria using ISNUMBER/MATCH
You can use DSUM, which will be more flexible. Like if you want to change the name of Salesman or the Quote Month, you need not change the formula, but only some criteria cells. Please see the link below for details...Even the criteria can be formula to copied from other sheets
http://office.microsoft.com/en-us/excel-help/dsum-function-HP010342460.aspx?CTT=1
You might consider referencing the actual date/time in the source column for Quote_Month, then you could transform your OR into a couple of ANDs, something like (assuing the date's in something I've chosen to call Quote_Date)
=SUMIFS(Quote_Value,"<=90",Quote_Date,">="&DATE(2013,11,1),Quote_Date,"<="&DATE(2013,12,31),Salesman,"=JBloggs",Days_To_Close)
(I moved the interesting conditions to the front).
This approach works here because that "OR" condition is actually specifying a date range - it might not work in other cases.
Quote_Month (Worksheet!$D:$D) contains a formula (=TEXT(Worksheet!$E:$E,"mmm-yy"))to convert a date/time number from another column into a text based month reference.
You can use OR by adding + in Sumproduct. See this
=SUMPRODUCT((Quote_Value)*(Salesman="JBloggs")*(Days_To_Close<=90)*((Quote_Month="Cond1")+(Quote_Month="Cond2")+(Quote_Month="Cond3")))
ScreenShot
Speed
SUMPRODUCT is faster than SUM arrays, i.e. having {} arrays in the SUM function. SUMIFS is 30% faster than SUMPRODUCT.
{SUM(SUMIFS({}))} vs SUMPRODUCT(SUMIFS({})) both works fine, but SUMPRODUCT feels a bit easier to write without the CTRL-SHIFT-ENTER to create the {}.
Preference
I personally prefer writing SUMPRODUCT(--(ISNUMBER(MATCH(...)))) over SUMPRODUCT(SUMIFS({})) for multiple criteria.
However, if you have a drop-down menu where you want to select specific characteristics or all, SUMPRODUCT(SUMIFS()), is the only way to go. (as for selecting "all", the value should enter in "<>" + "Whatever word you want as long as it's not part of the specific characteristics".
In order to get the formula to work place the cursor inside the formula and press ctr+shift+enter and then it will work!
With the following, it is easy to link the Cell address...
=SUM(SUMIFS(FAGLL03!$I$4:$I$1048576,FAGLL03!$A$4:$A$1048576,">="&INDIRECT("A"&ROW()),FAGLL03!$A$4:$A$1048576,"<="&INDIRECT("B"&ROW()),FAGLL03!$Q$4:$Q$1048576,E$2))
Can use address / substitute / Column functions as required to use Cell addresses in full DYNAMIC.

Returning multiple values with INDEX and MATCH without VBA

While i have seen this topic answered before i cant seem to understand the solution :(
Here is my worksheet:
https://docs.google.com/spreadsheet/pub?key=0AsCQyX3EZ40SdC1FNFBjVDh6d01iY2g0WnVXOU5GeFE&output=xls
As you can see i need the second INDEX in the first sheet to return the second value looked, but instead (as expected) it shows the first one again.
I am not the best with excel, explain slowly and i will understand fast!
Thanks in advance!
Try this "array formula" in Calculator sheet cell A3
=IFERROR(INDEX(IngredientDB!B$1:B$100,SMALL(IF(IngredientDB!$A$1:$A$100=$B$1,ROW(IngredientDB!$A$1:$A$100)),ROWS(A$3:A3))),"")
confirmed with CTRL+SHIFT+ENTER and copied across and down. When you run out of entries you get blanks - assumes up to 100 rows of data, increase as required
If you wanted to go the pivot table route you can start with this as a base and then customize it to your exact liking.:
Start with your info:
Then add a pivot of your data:
Then set the properties as so and then you can select the search terms, you can also change the settings to allow someone to type it in also:
The result will be as so:

Resources