I am using Excel 2013.
I have a table with three columns: Start Date, End Date, and Holiday - a column containing a formula to check if a holiday falls between the Start Date and End Date. The Start Date and End Date columns contain references to other columns where the date is calculated. The formula in the Holiday column uses an Index/Match function to look in a list of holidays (on a separate sheet called SLA Holidays). This table has thousands of records ranging over a one-week time span, and is updated daily.
The holiday formula does not work - it returns FALSE even when there is a holiday in the time frame. Upon evaluating the formula, it says that the first logical of the AND function is FALSE; however, it is true (9/3/2018 > 8/31/2018). The formula correctly evaluates the second logical of the AND function.
When I replace my table references to Start Date and End Date with references to cells outside of the table containing those dates, the formula works correctly.
Below is a screenshot of a few records from the table, showing the 3 columns. I've also included an HTML version for copy-ability. The formula is as follows:
{=AND(INDEX('SLA Holidays'!$A$2:$A$7,MATCH(MIN(ABS('SLA Holidays'!$A$2:$A$7-[#[Start Date]])),ABS('SLA Holidays'!$A$2:$A$7-[#[Start Date]]),0))>[#[Start Date]],INDEX('SLA Holidays'!$A$2:$A$7,MATCH(MIN(ABS('SLA Holidays'!$A$2:$A$7-[#[Start Date]])),ABS('SLA Holidays'!$A$2:$A$7-[#[Start Date]]),0))<[#[End Date]])}
Start Date End Date Holiday
08/31/2018 9/4/2018 FALSE
08/31/2018 9/4/2018 FALSE
08/31/2018 9/4/2018 FALSE
When I use the exact same formula, but switch the table references with cell references containing the same dates, the formula works. Here is that updated formula:
{=AND(INDEX('SLA Holidays'!$A$2:$A$7,MATCH(MIN(ABS('SLA Holidays'!$A$2:$A$7-AC5)),ABS('SLA Holidays'!$A$2:$A$7-AC5),0))>AC5,INDEX('SLA Holidays'!$A$2:$A$7,MATCH(MIN(ABS('SLA Holidays'!$A$2:$A$7-AC5)),ABS('SLA Holidays'!$A$2:$A$7-AC5),0))<AD5)}
Is there a way to make this formula work with references to dates within the table?
The Start Date and End Date columns contained formulas to calculate the dates, not just the actual date value. I changed my Holiday formula to include the Value function, taking the value of the table column references, and this solved the error.
Related
How can I check if an input_date falls between two dates (a date range) in excel, where the date range exists in a list of date ranges?
So I need to check if input_date falls between any date range, and then if it does, return the value of the date ranged it matched with. See the below table for an example.
Month
Start Date
End Date
Month 1
1/1/2022
1/31/2022
Month 2
2/1/2022
2/27/2022
Month 3
3/1/2022
3/31/2022
Input vs Expected Result
input_date
Expected Result = Month
1/25/2022
Month 1
2/3/2022
Month 2
I've tried using =IF(AND(A2>StartDate,A2<EndDate),TRUE, FALSE) but how can I check A2 against all date ranges in a list, and output the corresponding Month value? Is the best way really just nesting if statements for a fixed number of ranges? Any dynamic approach?
You may try using the either of formulas like shown below,
• Formula used in cell B7
=XLOOKUP(1,(A7>=$B$2:$B$4)*(A7<=$C$2:$C$4),$A$2:$A$4,"")
If one do not have access to XLOOKUP() then INDEX() & MATCH() can also be used,
• Formula used in cell C7
=INDEX($A$2:$A$4,MATCH(1,(A7>=$B$2:$B$4)*(A7<=$C$2:$C$4),0))
If you just require the text output of the month the input date is referring to then can you not just:
=TEXT(A2,"mmmm")
Or do you have a need for something outside of your example?
You can use the FILTER function to return the appropriate item from the "Month" column
If your Date Ranges are in a table named dateRange & the Input_Dateis inG2`:
=FILTER(dateRange[Month],(G2>=dateRange[Start Date]) * (G2<=dateRange[End Date]))
I am trying to calculate values within a specific date range. The data I want to split between each month and the values: Successful, Incomplete and Failed.
I've tried pivot tables with this data but it doesn't work for me, also lacking pivot table excel experience. Formulas I'm more comfortable with.
I am using the following statement to at least get the total number of a value I add into it;
=COUNTIF('Jan 19'!$C$2:$C$1159,"Value")
Ex. If I put into the value "Successful" I get the total number of successful records.
I am looking into having a formula that I can input a specific month/date range (Jan, Feb, etc) and a value to get a count.
Ex. =Formula ((RangeOfData, "Value") AND (RangeOfData, (FromDate, ToDate))
I expect to the get the total number of a value(s) within a specific date range. If there isn't any data then the results would be blank or 0.
I'd use the formula COUNTIFS() as #cybernetic.nomad pointed in the comments so you can put more conditions on the COUNT:
=+COUNTIFS('Jan 19'!$B$2:$B$1159,">="&F3,'Jan 19'!$B$2:$B$1159,"<"&G3,'Jan 19'!$C$2:$C$1159,H3)
In the formula above I guessed the dates are in the COLUMN B, if not, you need to change it in the formula above.
To do that we should put the range we want to look at in a couple of cells where you would put the date range, in the example above:
F3 is the start date (if you want February of this year should be 1/2/2019).
G3 is the final date (if you want February of this year should be 1/3/2019).
H3 is where you can write "value", "successful" or any other string you are trying to count.
My data model has a column named rowDate. This column has several repeating instances of dates due to the fact that there are multiple rows of data for different times of a single day.
I've written a measure that sums the values in another column from the data model that I want to pull from. (We'll call this MyMeasure.)
I'm trying to write a CUBEVALUE formula that extracts the total of MyMeasure when rowDate equals the value of a cell in a worksheet. (This will allow the result of the CUBEVALUE to change based on the date that the user inputs into cell B2.)
e.g.
Cell B2 = "2018-06-29" (date formatted)
=CUBEVALUE("ThisWorkbookDataModel","[MyMeasure]","[Summary Data].[rowDate].["&$B$2&"]")
This always returns #N/A. I have another column with data (a number) that I can write the exact same CUBEVALUE formula, but referencing the appropriate cell, and it works just fine. It's just this date column that I can't figure out.
Found the solution in this thread. The trick is to format the date in your targeted cell inline using the TEXT function to match the cube's default date format (YYYY-MM-DDTHH:MM:SS).
=CUBEVALUE("ThisWorkbookDataModel","[Measures].[MyMeasure]","[Summary Data].[rowDate].&["&TEXT($B$2,"YYYY-MM-DDTHH:MM:SS")&"]")
I better show you. This is how my list looks like:
And this is how I want it to be:
Basically, in the first picture I have different date ranges, for each date range I have a those two metrics, Sessions and Users and the final result should be a sort of explosion of all date ranges into single dates, considering that certain dates can be included in more than 1 date ranges (e.g. date 2017-08-12) is included in both first and second row.
And last but no least, the end date shouldn´t be counted.
Can someone help me out?
Thanks a million
A.
This is the outline of a solution:
Split each from/to date in your input table into its 2 constituent dates. You will need to use the string functions (LEFT, RIGHT and MID) to extract the numbers for the year, month and day values. These will still be strings of characters, so use the VALUE function to convert them to actual numbers and then use the DATE function to assemble them into a proper date value in Excel. (You may need to format your results using a date format, as Excel stores its dates as number of days since 01/01/1900, so 11/08/2017 is held in Excel as 42958.) Add as many helper columns as you need to your input table to achieve this.
Subtract 1 from each end date, this corrects the dates ranges so that the end date is included.
The first start date and the last end date define the range of output dates. So start your output table with the first date and in the cell below use a formula to add 1 to this date and copy the formula downwards until you get to your last possible output date.
To get the results for each possible output date, you need to find
which date ranges it belongs to. It belongs to a date range if it is
greater than or equal to the range's start date and less than or
equal to the end date. However, rather than comparing each output
date with individual start and end dates it is possible to compare
each output date with all the start and all the end dates at once. An expression such as A10>=E2:E7 generates an array of 6 elements with values
TRUE and FALSE according to whether A10 is greater than or equal to
E2, E3, E4, E5, E6 and E7 respectively. So, you can use this approach to generate an array of TRUE/FALSEvalues showing whether a particular output date is greater than or equal to (ie on or after) each range's start date. Similarly, you can get an array showing whether the same output date is less than or equal to (ie on or before) each range's end date.
The versatile SUMPRODUCT function can now be used to combine the arrays and the relevant sessions/users values from the input table to get the relevant values for the output date. For example, if the start dates are in E2:E7, the end dates in F2:F7, the sessions in B2:B7 and the output date in A10 then a sutable formula for determining the number of sessions to attribute to the output date would be =SUMPRODUCT(($A10>=$E$2:$E$7)*($A10<=$F$2:$F$7)*(B$2:B$7)). This formula could be copied to give results for all output dates and, assuming the input data for users is in C2:C7, it will also give the results for users if copied into the column adjacent to the sessions results. In this formula, the TRUE and FALSE values are effectively converted to 1 and 0, respectively.
A few points: (i) if you don't know how dates work in Excel then find out, it makes tasks such calculating the number of days between two dates or the date n days before/after a particular date extremely easy using simple arithmetic; (ii) don't confuse strings of text which look like dates with dates that can be manipulated arithmetically in Excel; (iii) I believe there are some errors in your example - 16/08/2017 is a date in two of your input ranges and should have results of (2,2) not (1,1) and 17/08/2017 is similarly in error.
I have used this approach in the illustration below and, to test its robustness, I have added an extra row of input data which has sessions different from users and which yields one date (19/08/2017) which does not match to any input range.
The output date range was generated as follows:
Cell A10: use formula =E2
Cell A11: use formula =1+A2
Cells A12, A13, ... copy formula in cell A11
Here's what I'm looking for....
Trying to Sum the count of worksheet 'Results 2013' column G items
IF Cell A matches "Canada"
IF Cell E (date) is July
Having trouble with the date portion of the SUMIFS statement below.
SUMIFS('Results 2013'!$G$2:$G$510,'Results 2013'!$A2:$A$510
,"=Canada",'Results 2013'!$E2:$E510,MONTH('Results 2013'!$E2:$E510)=7)
Example value of "Results 2013"$E$480 is
I try this formula, and it provides back "January" which is obviously incorrect.
=TEXT(MONTH('Results 2013'!$E$480),"mmmm")
However, this formula, results in TRUE or 1
=IF(MONTH('Results 2013'!$E$480)=7,1,0)
The simplest solution is to add a column Month using the MONTH function to compute values, and then refer to this new column in SUMIFS.
This tests whether the date values in column E fall within the range 7/1/2013 and 7/31/2013. If your dates all fall within 2013, it will work.
SUMIFS('Results 2013'!$G$2:$G$510,'Results 2013'!$A2:$A$510,"=Canada",
'Results 2013'!$E2:$E510,">="&DATE(2013,7,1),
'Results 2013'!$E2:$E510,"<="&DATE(2013,7,31))
This array formula will work with the more general case of dates falling within any year:
=SUM(G2:G510*(A2:A510="Canada")*(MONTH(E2:E510)=7))
You could use an array formula , then you can use month on the entire column:
{SUM(if('Results 2013'!$A2:$A$510="Canada",1,0)*if(MONTH('Results 2013'!$E2:$E510)=7,'Results 2013'!$G$2:$G$510,0))}
just remember to use ctrl+shift+enter rather than the usual enter to finish the formula