Cognos report studio last day of month - cognos

I'm using the following filter, but it's not including any transactions from the last day of the month. I think this filter assumes 12:01am. I need to include through 11:59:59PM.
[TRL_DATE]<=_last_of_month(?ReportDate?)

cast([TRL_DATE], date) <= cast(_last_of_month(?ReportDate?), date)

Related

Cognos Query to calculate a run date

So in my Cognos report I have a column 'Last Separation Date'. I want run a query on that column to calculate to all persons currently employed or separated from employment within the last two years. However, this date query should auto run to the day I'm running the report. For example. I run the report today 2/22/2020 and view data for the last two year till 2/22/2018. I login few days later to view the report on 3/1/2020. The report should pull data from 3/1/2018.
Create a filter with the between function using current date and some expression which determines a date two years in the past.
https://www.ibm.com/support/knowledgecenter/SSEP7J_11.0.0/com.ibm.swg.ba.cognos.ca_mdlg.doc/c_sql99_current_date.html#sql99_current_date
_add_years or _add_days might be handy as they take negative numbers.
Using the previous answers suggestions, your detail filter would be similar to
[Last Separation Date] between current_date and _add_years(current_date,-2)

Calculating Yearly Average by current month

I need to create a SS that calculates the yearly average from January until the end of the previous month.
Excel Example
Currently I have =SUM(A2:G2)/12 and each month I go in an change the range, but I would like it to update each month to include the month that just finished.
Any help would be appreciated.
Perhaps:
=IF(TEXT(TODAY(),"mmm")="Jan",0,SUM(A2:INDEX(A2:L2,,MATCH(TEXT(TODAY(),"mmm"),$A$1:$L$1,0)-1))/12)
Alternate:
=IF(MONTH(TODAY())=1,0,SUM(A2:INDEX(A2:L2,,MONTH(TODAY())-1))/12)
If laid out as shown above:
=AGGREGATE(1,6,A2,OFFSET(A2,,MONTH(TODAY())-2))
I am adding minus 2 to go to prior month and Aggregate function to allow me to specify to ignore any error values.

DAX year over year comparison

In a report that I am making in DAX I would like to have year over year comparison of a measure defined as:
Sales Count := CALCULATE(COUNT(fData[PN]);fData[Proc.Type]="CU")
This measure basically counts the amount of sales that were generated. I have a dataset that spans from the beginning of 2014 up to today (16/01/2018). My calendar table consists of a date column, a year column and a month column and is ranges from 01/01/2014 up to 31/12/2018 (to avoid contiguous date errors when using time intelligence functions).
I have defined a measure called PY Sales count as:
PY Sales Count := CALCULATE([Sales Count];SAMEPERIODLASTYEAR(dCalendar[Dates]))
This measure does the job I want it to do, aside from one issue. When comparing the month of january of this year to the month of January to last year, it appears that we are doing terrible. This is because the SAMEPERIODLASTYEAR function considers the FULL month of January for the year 2017 and compares it to the period from the first of January until the 16th of January (today).
I think I should thus try to build a custom measure to 'filter' the date table such that when the year over year measure considers the running month, it only takes the same period as the one on which sales were recorded to compare against, not the full period...
However, due to my sparse DAX experience, I cannot seem to get this right...
If anyone could help/assist me on this, that would be hugely appreciated!
Thanks in advance
I haven't had a chance to test this, but try something along these lines:
PY Sales Count := CALCULATE([Sales Count];
FILTER(dCalendar;
dCalendar[Dates] <= DATEADD(TODAY(), -1, year);
SAMEPERIODLASTYEAR(dCalendar[Dates])))

How can i modify DATEDIFF to find results in the past?

I have created a Visual Studio report (database is dynamics crm 2011). This report shows me from now (today) all elements 13 months in the past.
DATEDIFF(Month, CRMAF_FilteredQuote.createdon, CURRENT_TIMESTAMP) <=13;
How should I modify this statement to get the results from the final day of the previous month? For example all documents from the 30th September through to 1st August?
Thank you very much for your ideas.
Peter
You can get last day of previous month using below given query
SELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE()),0))
To find all documents created between two dates (last day of previous month and today), use below given query
SELECT *
FROM Entity_Name
WHERE CreatedOn Between DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE()),0)) AND GETDATE()

Extract year from cognos report expression

I want to extract current year, last year in report expression field but am not able to get it.
date2timestamp(Today()) and Today()
This works fine to get date
_add_years(date2timestamp(Today()),1) and extract("year",Today())
but this shows error.
I wanted to show 2016, 2015 dynamically in my report as heading of cross-tab node.
If you use layout calculation try
substring(date2string(Today()),1,4)
for current year. And
string2int32(substring(date2string(Today()),1,4)) - 1
for previous year.
for current year:
extract('year', date2timestamp(today()))
for prior year:
extract('year', _add_years(date2timestamp(today()), -1))
This will give you an integer value that you can format using the normal Data Format options in the date item properties, for example to remove the thousands comma if desired.
Make a query with two data items.
For the previous year, one data item will have:
extract (year, _add_years(current_date, -1))
And for the current year:
extract (year, current_date).

Resources