I have two columns, Last Upload and Final Date. I have a formula to calculate the difference between today and the Last Upload using
=DATEDIF( [#[Last Upload]],TODAY(),"d")
However, sometimes the Last Upload column will be blank and in this case we would like to use the Final Date column instead.
Is there a way to combine and use the above statement when the column is not blank and the other when it is? I have been trying to nest it with an IF statement but struggling to do so.
You could use ISBLANK formula combined with IF formula.
=DATEDIF(IF(ISBLANK([#[Last Upload]]),[#[Final Date Upload]],[#[Last Upload]]),TODAY(),"d")
Alternative solution:
=DATEDIF(IF(LEN([#[Last Upload]]),[#[Last Upload]],[#[Final Date]]),TODAY(),"d")
LEN might be a little bit more error-proof than ISBLANK.
I want to avoid VBA as much as possible and try to find a solution in a single cell--if possible. I have been trying to find a way to do so, but I have no idea how to.
The logic is summarized in the image below. In words, the conditions are:
Search Name is looked for in the Name column of the right table.
Search Date has to be greater than the Date in the right table.
Search Date minus Date has to be the positive minimum value.
Return the Pay that matches the criteria--which is 500 in the example.
You could use the following array formula (i.e. you need to enter it with Ctrl+Shift+Enter, if you are successful, you will see the braces appear in the formula bar):
=INDEX(G:G,MATCH(A2,IF(F:F=B2,E:E)))
The formula will return #N/A if there are no dates earlier than the Search Date.
NOTE: The dates have to be sorted in ascending order for this to work
EDIT: A little more robust that doesn't require sorting:
=INDEX(G:G,MATCH(MAX(IF((F:F=B2)*(E:E<A2),E:E)-A2),IF((F:F=B2)*(E:E<A2),E:E)-A2,0))
Note: Since this doesn't use MATCH, you won't get #N/A in case there are no dates earlier than the Search Date and you will instead get Pay (i.e. the header). If you want to get something else, then you can wrap the whole function in an IFERROR, relying on the fact that excel returns an error if one attempts to multiply a text with a number, something like this:
=IFERROR(Formula*1, "No pay matched")
This can be done with SumProduct, which does not require Ctrl-Shift-Enter
=SUMPRODUCT($G$2:$G$9,(A2>$E$2:$E$9)*(MONTH(A2)=MONTH($E$2:$E$9)*($F$2:$F$9=B2)))
The logic commands that the Search Date is in the same month as the Date column.
If you have the new Dynamic Array functions, that are currently in preview in the Insider Fast build of Excel 365, you can use
=FILTER($G$2:$G$9,(A2>$E$2:$E$9)*(MONTH(A2)=MONTH($E$2:$E$9)*($F$2:$F$9=B2)))
I am not an expert in Excel but I have been using the format.
I am trying to make a roster of my staff in Excel sheet using formulas.
The 1st sheet I have uses the row name TIME as a priority and fills other columns with staff names.
Now in the 2nd sheet, I want to use a formula in each staff ROW and the column automatically fills with the TIME at each name.
Please help me if possible.
Thank you.
Use INDEX / MATCH combo. Something like this:
=IFERROR(INDEX(Sheet1!$B$3:$B$9,MATCH($A2,Sheet1!C$3:C$9,0)),"OFF DAY")
Syntax:
=INDEX(rng,index_number) — returns the value based on the index number
=MATCH(lookup_value,rng) — returns the relative position of the lookup value
=INDEX(rng,MATCH(lookup_value,rng)) — we know all the arguments except for one — index_number. Since the output of MATCH function is the same as the index_number, we're going to substitute the index_number with MATCH function.
You can almost think of the INDEX/MATCH combo as:
=INDEX/MATCH(rng,search_value)
=IFERROR(value_or_expression_to_evaluate,value_to_return_if_error) — and finally, we're going to wrap our formula with this one, which will return a value if there is no match, which means, in your example, employee is on-leave, on a rest-day, or whatever. Can be =IFNA, too.
Now, to return all values with multiple matched lookup_value just like in your example, where "Tam" have two shifts on Monday, you may use a trailing number with employee names, i.e. "Tam1" and "Tam2" to indicate the number of shift in a given day. Or you may also use a combination of COUNTIF function (to count the number of shift of "Tam") and CONCATENATE to join the results together so that the output is gonna be: 630-1430 / 1230-2200. There are many ways to do it depending on your requirement.
Hope this helps..
I could use some help with Excel's LOOKUP function please...
I have this formula designed to reference the last value (they are dates) in a row (non blank) and then return me the value in the title row above it. This one works great...
=INDEX($L$4:$BB16,1,((LOOKUP(2,1/(L16:BB16<>""),COLUMN(L16:BB16)))-10))
However I now need to also add the criteria that the date can not be bigger than today's date. So I've added an AND function in the criteria hoping that would do the trick as follows:
=INDEX($L$4:$BB10,1,((LOOKUP(2,1/(AND(ISNUMBER(L10:BB10),L10:BB10<=TODAY())),COLUMN(L10:BB10)))-10))
but this formula doesn't seem to be working. I'm not too sure why. In a nutshell I need the Lookup function to be able to handle two criteria (not blank and also date less than today). Any thoughts or advice??
Thanks!
Use:
=INDEX($4:$4,AGGREGATE(14,6,COLUMN(L16:BB16)/((L16:BB16<>"")*(L16:BB16<=TODAY())),1))
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.