Cognos Query to calculate a run date - cognos

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)

Related

Is there a way to find the time between 2 dates after subtracting in excel?

I am given this task to complete
"What is the average time for a project to go to 3-Offered per year for the years 2016, 2017, and 2018? Use the formula # Days = [Date Offered] - [Start Date].
Only projects where [Project Template] = "Pre-Approval" will have an offered date, no need to include Fast Track projects in the data."
my current function I am trying to use is
=AVERAGE(IF((B:B="Pre-Approval")*(C:C="3-Offered")*(YEAR(D:D)=2016),E:E-D:D)) but I am getting the #VALUE! and I'm not sure why.
I will link a screenshot of some of the data used for this task.
[Column D is the start date and Column E is the Offered Date]
I think it is easier if you break down the problem into smaller pieces.
First, I would separate the years from the offered date. On a different column, e.g. Year, I would apply =YEAR() for every item in your Offered Date column.
Second, I would take another column, call it Diff, and apply =OfferedDate-StartDate.
Then, for each individual year I would apply =AVERAGEIFS(diff_column_range, year_column_range, "3-Offered", year_column, required_year)
I have an example for you here: https://1drv.ms/x/s!AhMbe-MPmuFCggjutWepn-QtMri4?e=CxpTCW
Let me know if this works for you.
Cheers!

Count of customers scheduling service dates in consecutive years

I am brand new to Spotfire (using 7.7) and am hitting a roadblock on a simple task so am hoping for some assistance.
I need a count of customers that are scheduling service dates in consecutive years.
Since users will be using different date filters I created a MaxServiceDate calculated column to give me the max date depending on the filter and from there subtract a year to give me a PreviousYear calculated column.
Then my thought is then do a distinct count of all CustomerIDs which have a ServiceDate that match the MaxServiceDate and PreviousYear. The issue I'm running into is I don't know how to group by or fix the CustomerID in order to loop through the ServiceDates and check if they have dates matching my criteria.
Thanks for any help.
Sample data:
You can create a secondary table with a pivot transformation having the max(ServiceDate) and customer ID. The join that table back with your original so that you have the maxdate for each customer on your main table. Then do a calculated column based on the Max(ServiceDate) and Service date to determine if > 365 days.
Pivot Transformation
I think a calculated column like the following would meet your needs:
If((Max(Year([ServiceDate])) over (Intersect([CustomerID])) - Min(Year([ServiceDate])) over (Intersect([CustomerID])) + 1)=UniqueCount(Year([ServiceDate])) over (Intersect([CustomerID])),"good","bad")
For each customer, take their max service date year and subtract their min service date year and add +1. This number should match the number of distinct years associated to that customer's service dates.
This will tell you if a particular customer (at least while you had that customer) had service done in consecutive years or not.

Editing formula within multiple calculated fields concurrently

I have a pivot table with monthly run-rate forecast.
e.g. on the 5th of Jan it would be [number]/5 *31
I change it every week so 5th/ 12th/19th etc.
Only problem is I have lots of fields like this and lots of tables and lots of sheets. Is there any way to update the calculated fields in bulk?
Thanks
You should consider now() formatted to give the week. Then call that value in your calcs... should update with every change of week

Calculate average based on a value column (count) in a pivot table

I'm looking a way to add an extra column in a pivot table that that averages the sum of the count for the months ("Count of records" column) within a time period that is selected (currently 2016 - one month, 2017 - full year, 2018 - 5 month). Every month would have the same number based on the year average, needs to be dynamically changing when selecting different period: full year or for example 4 months. I need the column within the pivot table, so it could be used for a future pivot chart.
I can't simply use average as all my records appear only once and I use Count to aggregate those numbers ("Count of records" column).
My current data looks like this:
The final result should look like this:
I assume that it somehow can be done with the help of "calculated filed" option but I couldn't make it work now.
Greatly appreciate any help!
Using the DataModel (built in to Excel 2013 and later) you can write really cool formulas inside PivotTables called Measures that can do this kind of thing. Take the example below:
As you can see, the Cust Count & Average field gives a count of transactions by month but also gives the average of those monthly readings for the subtotal lines (i.e. the 2017 Total and 2018 Total lines) using the below DAX formula:
=AVERAGEX(SUMMARIZE(Table1,[Customer (Month)],"x",COUNTA(Table1[Customer])),[x])
That just says "Summarize this table by count of the customer field by month, call the resulting summarization field 'x', and then give me the average of that field x".
Because DAX measures are executed within the context of the PivotTable, you get the count that you want for months, and you get the average that you want for the yearly subtotals.
Hard to explain, but demonstrates that DAX can certainly do this for you.
See my answer at the following link for an example of how to add data to the DataModel and how to subsequently write measures:
Using the Excel SMALL function with filtering criteria AND ignoring zeros
I also recommend grabbing yourself a book called Supercharge Excel when you learn to write DAX by Matt Allington, and perhaps even taking his awesome online course, because it covers this kind of thing very well, and will save you significant head-scratching compared to going it alone.

Calculate % Change in Cognos Report Studio

Is it possible to calculate a percentage change in a Cognos Report?
Currently, I have a crosstab that has years as the columns and widgets in the rows with a calculation of total revenue. I am looking to calculate the annual % increase. New to Cognos, but I could accomplish this using other tools.
Any help will be very much appreciated.
Sorry for the late answer to your question but perhaps it will help others who see it.
It's kind of annoying, but it can be done. If you have one Query which uses an input parameter to select the year, perhaps it is a filter that says [Year] = ?YearPrompt?, then you can make a second Query which uses the filter [Year] = ?YearPrompt? - 1. Then, you can join these two queries, and the third query (made by joining the first two) will have both this year's revenue, and last year's revenue, available to it for a calculation, such as what the percent change is.
You need to create a query calculation item as one of the columns and in it you take Year2 - Year1(You can choose the exact columns you already have in the report using the Data Items tab when you are making the query calc) Also make sure you make this query calc a % in its format.

Resources