Counting cells that have data in given month - excel

I have a database that collects employee training dates and offer dates and I want to see how many employees have been trained in a given month.
My below formula checks B2's date and then counts offers in that month that have completed training, but I must be going wrong as it appears to be multiplying the figure.
=SUMPRODUCT((COUNTIF(Database[Training Date],"*"))*(MONTH(Database[Offered Date])=MONTH(B2))*(YEAR(Database[Offered Date])=YEAR(B2)))
All I want it to do is count if the employee has a training date and ignore the blank cells in a given month.
Database Table:
************************************************
* Employee * Training Date * Offered Date *
************************************************
* John * YES * 21/02/2016 *
* Joe * YES * 18/02/2016 *
* Suzy * * 16/02/2016 *
************************************************

If you have xl2007 or newer, try the COUNTIFS function.
=COUNTIFS(database[training date], "yes", database[offered date], ">"&EOMONTH(B2, -1), database[offered date], "<="&EOMONTH(B2, 0))
The COUNIFS function is vastly superior to the the older SUMPRODUCT function in terms of calculation load; typically 25-35%.
Your own formula could have discarded the COUNTIF function and just replied on the SUMPRODUCT.
=SUMPRODUCT((database[training date]="yes")*(MONTH(database[offered date])=MONTH(B2))*(YEAR(database[offered date])=YEAR(B2)))

Related

Trying to show a full years amount based on a smaller fraction of the year's total

this is my first post.
Right now, I have a limited set of data ranging from the beginning of this financial year until now. I'm trying to show what a full year's worth of that data would look like.
For example, if the number is at 10, and the data range is from 1/07/2021 - 30/12/2021 (half the year), then the end output should be 20. Or for example, turn a 12 with 3/4 of the year date range to 16 for a full years' worth.
However, my current formula would end up with 15 (10 + "half") rather than (10 + 10)
Right now this is what I have, but I know there's something off on my logic, as the output is smaller than it should be:
D1+((364-(F1-E1))/365)*D1
where E1 is the start date and F1 is the end date, and d1 is the number for that date range
Thanks in advance
endDate - startDate will give you the number of days the data covers.
(endDate - startDate) / 365 will give you what fraction of a year the sample represents.
Let’s say this works out to be 30%, or 0.30.
annualValue * 0.30 = periodValue and therefore we know that periodValue / 0.30 = annualValue.
So there it is, the cell you want the Annual Value in should be:
= periodValue / ( ( endDate - startDate) / 365 )
I will leave it to you to replace each of the three named values in my example to be the correct cell references. I suspect that’s probably:
=D1/((F1-E1)/365) which is the same as (D1*365)/(F1-E1).
The easy way to remember this is that it’s just cross-multiplication.
periodValue / days is proportionate to annualValue / 365. Thus periodValue / days = annualValue / 365. Cross-multiply and you get periodValue * 365 = annualValue * days. Divide both sides by days and you get `annualValue = (periodValue * 365)/days.

Sumifs with date difference in range

I have a spreadsheet with:
list of recurrent expenses
other lists of recurring stuff, not important
an estimation of inflow and outflow monthly
The estimation is calculated with the following criteria (in AND logic):
date is between "since" and "to" (if since is empty, it is always valid, and the same for "to")
the month is a multiple of "every month" starting from "since", i.e. the voice must be included if "data" = "since" + "every months" * x, where x is an integer number
I wanted to create a sumifs like the following (Italian Excel, sorry):
=SOMMA.PIÙ.SE('Uscite'!$E$2:$E$1048576;'Uscite'!$C$2:$C$1048576;"<="&'v3'!$A2;'Uscite'!$D$2:$D$1048576;">="&'v3'!$A2;?????)
where ????? is the missing piece: I considered using a DATEDIF with "m", in order to get the difference in months between cell Ax and 'Uscite'!Since, then verifying if this difference is a perfect multiple of "every months", but no clue how to do it.
Any suggestion?
Thanks for your time!
In english formulation, you could do:
=SUM( 'Entrate ricorrenti'!$E$2:$E$100 *
( ('Entrate ricorrenti'!$D$2:$D$100 >= 'v3'!A2) + ISBLANK('Entrate ricorrenti'!$D$2:$D$100) ) *
IFERROR( MOD( DATEDIF( 'Entrate ricorrenti'!$C$2:$C$100, 'v3'!A2, "M" ), 'Entrate ricorrenti'!$B$2:$B$100 ) = 0,
0 ) )
In Italian:
=SOMMA( 'Entrate ricorrenti'!$E$2:$E$100 *
( ('Entrate ricorrenti'!$D$2:$D$100 >= 'v3'!A2) + VAL.VUOTO('Entrate ricorrenti'!$D$2:$D$100) ) *
SE.ERRORE( RESTO( DATA.DIFF( 'Entrate ricorrenti'!$C$2:$C$100; 'v3'!A2; "M" ); 'Entrate ricorrenti'!$B$2:$B$100 ) = 0;
0 ) )
So, this uses the very nice dinosaur function that you taught me about today. I have never seen this except for DAX.
It simply filters out the payments that stopped before the target date, ('v3'!A2) by multiplying the payment values, ('Entrate ricorrenti'!$E$2:$E$100), times the boolean expression
(('Entrate ricorrenti'!$D$2:$D$100 >= 'v3'!A2) + ISBLANK('Entrate ricorrenti'!$D$2:$D$100))
that also checks to see if the To Date is blank. Then it multiplies that times the modulo of the DATEDIF in months by the Frequency in months. If that is zero, then a payment lands in that month. DATEDIF has the nice property that if the date difference is negative, it generates an N/A error. This allows us to wrap it in an IFERROR to replace that with zero - this prevents the formula from including payments that have not yet started.

FY vs last FY Cognos 11

I am looking to generate report in Cognos 11 for attended appointments for this FY vs last FY for the same time frame. For example of I am running report on 1st June 2021, I should get data for sum of appointments of April and May 2021 and sum of appointments of April and May 2020.
Please let me know how can I set the date filter.
Thanks
You didn't provide any context. There are many ways to do this. Just providing a filter expression won't work because I don't know what the rest of your report looks like.
Describing such a general solution for Cognos in plain text is not simple. I'll also assume that, since you are using Cognos, the database structure is a star schema containing a time dimension with columns named [FiscalYear] and [FiscalMonthNumber] that are integers. Also, that your fiscal year runs from January 1 to December 31.
Using Cognos functions:
[FiscalYear] * 100 + [FiscalMonthNumber]
between
_year(_add_months(current_date, -2)) * 100 +
_month(_add_months(current_date, -2))
and
_year(_add_months(current_date, -1)) * 100 +
_month(_add_months(current_date, -1))
or
[FiscalYear] * 100 + [FiscalMonthNumber] + 100
between
_year(_add_months(current_date, -2)) * 100 +
_month(_add_months(current_date, -2))
and
_year(_add_months(current_date, -1)) * 100 +
_month(_add_months(current_date, -1))
Using Cognos macros:
[FiscalYear] * 100 + [FiscalMonthNumber]
between
#timestampMask (_add_months($current_timestamp, -2), 'yyyymm')#
and
#timestampMask (_add_months($current_timestamp, -1), 'yyyymm')#
or
[FiscalYear] * 100 + [FiscalMonthNumber] + 100
between
#timestampMask (_add_months($current_timestamp, -2), 'yyyymm')#
and
#timestampMask (_add_months($current_timestamp, -1), 'yyyymm')#
The advantage of using the Cognos macro is that the value is computed once before sending to the database server, rather than the database server computing it for every row.
Assumption that you have a data item like invoice date, etc, for the example this will be [Date] but you could change the filter to what makes sense based on your data items
The filter could use a date prompt with a parm i.e. PrmDate or use Current_date
see explanation below
Filter should look like:
([Date] between [CurrentStart] and [CurrentEnd])
OR
([Date] between [PriorStart] and [PriorEnd])
Create some data items to make this a little easier
Offset, note: the offset allows you to change your starting month/period
This would be for January
extract(month, current_date) -1
This would be for April
extract(month, current_date) -4
CurrentStart
_first_of_month (_add_months(current_date, -[Offset]))
CurrentEnd, note: if you don't want a prompt, just swap ?PrmDate? with Current_date
_add_months(?PrmDate?,-1)
PriorStart
_add_years([CurrentStart], -1)
PriorEnd
_add_years([CurrentEnd],-1)

Vlookup on another table with multiple criteria

Hi,
I have a list of payments and a table with the promises that collection officers made.
I want assign into the payment table by id (and date) the last collection officer that made the agreement with the debtor.
For example: On id 1111 there were two promises made: by Morticia Adams and Gulliver; But i choose Gulliver because he made the last promise in that date range taking in account the date of payment.
Likewise for id 5425 the last promise made was made by Marie Anne because 23.10.2016 (date of payment) is between 12.10.2016 and 26.10.2016 (promise dates).
I would be really grateful if somebody could guide me through this.
Thanks you!
Disclaimer: this formula generates what OP is describing, not what the picture is showing.
One way to do this is by finding the latest conversation date that satisfies the conditions:
The payment ID of the row in the promises table is equal to the payment id of the payments table.
The date of the payment is greater than or equal to the conversation date.
The date of the payment is less than or equal to the agreed payment date.
Which we can do like this:
{=MAX(($A$3:$A$8 = A12) * (B12 >= $B$3:$B$8) * (B12 <= $C$3:$C$8) * $B$3:$B$8)}
And then combining the date with the payment ID to have a unique key that we can use to look up the name.
{=MAX(($A$3:$A$8 = A12) * (B12 >= $B$3:$B$8) * (B12 <= $C$3:$C$8) * $B$3:$B$8) & A12}
And lastly we can perform an Index match, looking up the output of the above formula in the concatenated range of date and payment ID in the promises table
{=INDEX(
$D$3:$D$8,
MATCH(
MAX(($A$3:$A$8 = A14) * (B14 >= $B$3:$B$8) * (B14 <= $C$3:$C$8) * $B$3:$B$8) & A14,
$B$3:$B$8 & $A$3:$A$8,
0))}
The {} means you have to enter the formula using Ctrl + Shift + Enter
Note that this will be a lot more readable and intuitive if you name the ranges.

MS Excel - Date Analysis

I am using MS Excel to do my data analysis. I have two dates. One date is my forecast date. For example, i am forecasting the stock to arrive - 06/09/2009. Another date is the actual stock arrival date - 06/10/2009.
I know that the date difference is 1 day. What I would like to calculate is the accuracy of my forecasting. If forecast date is same as actual arrival date then it should be 100%.
I am trying to find the function in excel to do this calculation. Is there any?
Thanks.
If you are just working with dates and the accuracy is days then you can just subtract one day from the other.
For example if you had one column with expected date(in A1), one with actual date (in B1) then the next column could be difference (in C1).
=SUM(b1 - a1)
at the bottom of the C column, supposing you had 4 rows you would just do an average of the days
=AVERAGE(C1:C4)
that would give you the accuracy of your preditions.
Hope that helps
Generally
% accuracy = 100% - %abs(error) = 100% * [1 - abs(forecast - actual) / actual ]
Since the values of dates are not well-defined, you could normalize them by subtracting some initial date. For the above formula, this initial date will cancel out in the numerator, so you could just use:
100% * [1 - abs(forecast - actual) / (actual - initial)].
In Excel, the formula formatted for % would be: =1-ABS(C2-B2)/(B2-A2)
Using your example:
initial actual arrival forecast arrival % accuracy
01/01/09 06/10/09 06/09/09 99.38%

Resources