How to count events after set date with COUNTIFS? - date

I'm creating this report in spreadsheet
https://docs.google.com/spreadsheets/d/1U48MybVshKT3eRYE9goRCab9k1KCoXe7Zsr9Ogkkm4Y/edit?usp=sharing
In "BD" you can find the records and in "NB-month" the KPI that I want to analyze; I would like to create DATE filter for the numbers in the columns, ex for the col: "nº Contract closed" I'm thinking to use this formula:
=COUNTIFS(BD!R:R;A5;BD!G:G;">"&DATE(B2))
but I get a value: "0" that is incorrect because for this agent "Carla Vaello" the number of contracts closed after 2020-02-01 should be "2".

your usage of DATE formula is wrong (DATE requires 3 parameters). either change DATE to DATEVALUE or use:
=COUNTIFS(BD!R:R; A5; BD!G:G; ">"&B2)

Related

Sum values associated with a date equal to or less than today in Google Sheets [duplicate]

This question already has an answer here:
How to compare dates or date against today with query on google sheets?
(1 answer)
Closed 5 months ago.
So I have a table that looks like this:
date
goal
10/1/2022
10000
10/2/2022
10000
10/3/2022
10000
10/4/2022
10000
10/5/2022
10000
10/6/2022
10000
I would like to create a formula that Sums the goal column for the dates less than or equal to the current day. I currently have this:
=query(A4:B1000, "select SUM(B) WHERE A <= today()")
But this is throwing the following error: Unable to parse query string for Function QUERY parameter 2: PARSE_ERROR: Encountered " "(" "( "" at line 1, column 31. Was expecting one of: <EOF> "group" ... "pivot" ... "order" ... "skipping" ... "limit" ... "offset" ... "label" ... "format" ... "options" ... "and"
Any thoughts on how to proceed would be helpful. Thanks!
This is a typical use case for SUMIF, which will sum values in a range that meet a condition (a condition on that same range, or on a corresponding range):
=sumif(A4:A1000,"<="&TODAY(),B4:B1000)
will sum the values in B4:B1000 for which the corresponding value in A4:A1000 is less than or equal to today.
Or you can still use a query if you prefer as long as you get the right syntax - see this for example.
=query(A2:B1000, "select SUM(B) WHERE A <= date '"& text(today(),"yyyy-mm-dd")&"'")
Dates in my locale are in dd/mm/yyyy format so 6/10/2022 is tomorrow at time of writing.

Get months names between two dates Ms-Access

I have this query
SELECT TblSales.ProductCode, TblSales.ProductName, TblSales.QtySold, Right([Zdate],7) AS [Mn/Yr]
FROM TblSales
WHERE (((TblSales.zDate) Between [Forms]![FrmSales]![From] And [Forms]![FrmSales]![FinalTo]))
GROUP BY TblSales.ProductCode, TblSales.ProductName, TblSales.QtySold, Right([Zdate],7);
I need this result to be like these columns (ProductCode-ProductName-Sum Of QtySold in First month from the given date - Second month - Third month - and so on)
Example : If the two dates were #1-1-2018# To #31-3-2018# -These dates can be changed due to [Forms]![FrmSales]![From] And [Forms]![FrmSales]![FinalTo]-
Columns:
ProductCode -ProductName -Jan-2018 -Feb-2018- March-2018
Rows:
A1-Computer-2000-2500-3000
Previous Qty is the SumOfQtySold in every month between the two dates,Thanks in advance.
Edit #1 :
I couldn’t make a crosstab query and this message popup Crosstab Error
You can use a crosstab query to transpose row data into columns. Something like this:
PARAMETERS StartDate DateTime, EndDate DateTime;
TRANSFORM NZ(Sum(tblSales.QtySold), 0) AS SumOfQtySold
SELECT tblSales.ProductCode, tblSales.ProductName
FROM tblSales
WHERE (((tblSales.zDate) Between [StartDate] And [EndDate]))
GROUP BY tblSales.ProductCode, tblSales.ProductName
PIVOT Format([tblSales].zDate,"mmm-yyyy");

Calculate a Reference Date in DAX

Trying to nail down the syntax for a pretty straightforward problem.
I have a table called Events and a full-feature DATES table with a relationship between the Dates[Date] field.
Using the event name as a slicer, I trying to create a [First Monday] measure that will return the date of the first Monday of the month.
So for example, if my event date was 2/14/19, [First Monday] would return 2/4/19.
Your Date table needs to contain 2 columns:
Year-Month: for example, "2018-01"
Weekday Number: for example, 1 (for Monday); or Weekday Name (i.e, "Monday")
Then:
First Monday =
CALCULATE( MIN('Date'[Date]),
ALL('Date'),
VALUES('Date'[Year-Month]),
'Date'[Weekday Name] = "Monday")
How it works:
First, we need to access all dates in the Date table, so we use ALL()
Second, we need to see only dates for the current context year and month, for which we can use VALUES()
Third, for each month we only want Mondays, hence Date[Weekday] = "Monday"
All this unfiltering/filtering generates a set of Mondays for the Year-Month visible in the current filter context. All we need to do now is to find the earliest of the Mondays using Min(Date).

Tableau - compare average quantity before and after variable date

I have a dataset containing client names, license codes, billing dates, and billing quantity. What I need to do is analyze average quantity before and after a specific date. How I find that particular date per client is by looking for specific billing codes and returning the minimum date in that subset of data. I have attached a sample of the data.
For example, I need to find the minimum date for each name where the Billing code begins in “E”. For “Allen” this date would be August 2015. For “Ama” is would be May 2015. I then want to compare the average monthly quantity for those codes NOT beginning with “E” before the minimum date, and the average monthly quantity for those codes that do begin with “E” following that minimum date. For example, “Allen” would show approximately 50 units on average before August 2015 and approximately 78 units on average after August 2015, inclusive. “Ama” would show 19 and 24, respectively.
Ideally I would like to run a regression of the average quantities for each firm.
NAME|BILLING DATE|BILLING CODE|QUANTITY
----|------------|------------|--------
Allen|Jan-15|A11|64
Allen|Feb-15|A11|64
Allen|Mar-15|A11|64
Allen|Apr-15|A11|64
Allen|May-15|A11|65
Allen|Jun-15|A11|1
Allen|Jul-15|A11|1
Allen|Aug-15|A11|1
Allen|Sep-15|A11|1
Allen|Oct-15|A11|1
Allen|Nov-15|A11|1
Allen|Dec-15|A11|1
Allen|Jan-16|A11|1
Allen|Feb-16|A11|1
Allen|Mar-16|A11|1
Allen|Apr-16|A11|1
Allen|May-16|A11|1
Allen|Jun-16|A11|1
Allen|Jul-16|A11|1
Allen|Aug-16|A11|1
Allen|Jan-15|A22|4
Allen|Feb-15|A22|4
Allen|Mar-15|A22|4
Allen|Apr-15|A22|4
Allen|May-15|A22|4
Allen|Jun-15|A22|4
Allen|Jul-15|A22|4
Allen|Aug-15|A22|4
Allen|Aug-15|E11|38
Allen|Sep-15|E11|36
Allen|Oct-15|E11|40
Allen|Nov-15|E11|40
Allen|Dec-15|E11|40
Allen|Jan-16|E11|40
Allen|Feb-16|E11|40
Allen|Mar-16|E11|38
Allen|Apr-16|E11|38
Allen|May-16|E11|40
Allen|Jun-16|E11|40
Allen|Jul-16|E11|40
Allen|Aug-16|E11|39
Allen|Oct-15|E22|40
Allen|Nov-15|E22|40
Allen|Dec-15|E22|40
Allen|Jan-16|E22|40
Allen|Feb-16|E22|40
Allen|Mar-16|E22|38
Allen|Apr-16|E22|38
Allen|May-16|E22|40
Allen|Jun-16|E22|40
Allen|Jul-16|E22|40
Allen|Aug-16|E22|40
Ama|Jan-15|A11|21
Ama|Feb-15|A11|20
Ama|Mar-15|A11|20
Ama|Apr-15|A11|20
Ama|May-15|A11|20
Ama|Jun-15|A11|20
Ama|Jul-15|A11|20
Ama|Aug-15|A11|20
Ama|Sep-15|A11|18
Ama|Oct-15|A11|18
Ama|Nov-15|A11|18
Ama|Dec-15|A11|18
Ama|Jan-16|A11|18
Ama|Feb-16|A11|18
Ama|Mar-16|A11|18
Ama|Apr-16|A11|18
Ama|May-16|E11|24
Ama|Jun-16|E11|24
Ama|Jul-16|E11|28
Ama|Aug-16|E11|21
First, create a LOD calc that determines the cutoff date per client. Say start with a fixed LOD calc. See the docs on LOD calcs. For example, define Cutoff_Date as:
{ fixed Name : min(if startswith([Billing Code], "E") then [Billing Date] end) }
Then write a pair of calculated fields that return the quantity if the date is before (after) the cutoff date or null otherwise. Hint, in an if statement without an else clause, the default implicit else condition returns null.
For example, define Quantity_Before_Cutoff as:
if [Billing Date] < [Cutoff_Date] then [Quantity] end
and define Quantity_After_Cutoff similarly -- deciding which calculation should include quantities that were billed on the cutoff date.
Finally, you can use your 2 new measures as desired to calculate avg quantities before and after the cutoff date.
For your regression model, you might also want a Boolean valued calculated field that indicates whether a record is before or after the cutoff. Make it a dimension instead of a measure

crystal reports month date range for earnings

My client has a report that accepts a date range to get a report showing projected revenue. So, a user would enter a date range of '1/1/2015 to 1/31/2015' and the report should return data only in the range '1/1/2015 to 1/31/2015 grouped by week. I am instead for the week of 12/29/2014 (which 1/1/2015 fall into) and 2/1/2015 (which 1/31/2015 falls into). The report is intended to group by week, but I do not want days on the report that are earlier than the start date parameter or later than the end date parameter.
The sql statement for this report is:
SELECT job.job, job.status, job.customer_po, job.part_number, job.unit_price,
job.price_uofm, delivery.promiseddate, delivery.remaining_quantity, job.build_to_stock, job.description, job.make_quantity, job.pick_quantity, job.shipped_quantity, job.lead_days
FROM dbo.delivery as delivery RIGHT OUTER JOIN db.job as job on delivery.job = job.job
WHERE job.build_to_stock = 0 AND (job.status = 'active' OR job.status = 'hold' OR job.status = 'pending')
The date range is from this code and parameters:
Max – Maximum(?Date Range)
Min – Minimun(?Date Range)
Date Range - "From " & {#Min} & " to " & {#Max}
This is the group expression
Group 2 Name - GroupName ({#Adj Date 2}, "weekly") & " thru " & cdate(GroupName ({#Adj Date 2}, "weekly"))+6
This is the select expression
{#Date} = {?Date Range} and
not {Job.Build_To_Stock} and
{Job.Status} in ["Active", "Hold", "Pending"]
Do you know how I can prevent the "overflow" of dates outside of date range?
Thx
As long as you have date filtering in your record selection formula there will not be any "overflow" outside of that range. If you've got {Record.Date} in Minimum({?DateRange}) to Maximum({?DateRange}), which it sounds like you do, then your report will not contain any records outside of the parameter regardless of how you group them.
Your problem might stem from over-complicating or misinterpreting the grouping. All you need to do is group by {Record.Date} and select "Group by week" in the grouping options... you don't need any complicated formulas to break it out by week. But be aware that the way weeks are referred to is by their starting date. For example, if you had a record with a date of Feb. 19, 2015, that record would fall into the group labeled "Feb. 15, 2015" even if your {?DateRange} parameter was Feb. 18 - Feb. 15.