Solved

Cognos how to use the prompt dates in queries

Posted on 2008-06-16
3
1,194 Views
Last Modified: 2010-04-29
Hi

I have a report that uses date prompts to select data from contracts. (cognos8)

Basically you enter a start date and an end date and I have created queries that select data between those dates.

What I need to do though is count the number of emplyees on a contract for each month between the dates entered. for example if I enter the start prompt as 01/12/07 and the end prompt as 31/12/08 I want the count of employees from 01/12/07 to 31/12/07 and then the 01/01/08 to the 31/01/08 and then the same for Feb, March, April etc all the way to Dec 08 (end prompt date) and then add them all together at the end! Any ideas welcome!!
0
Comment
Question by:ac_davis2002
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
RWrigley earned 500 total points
ID: 21794827
I'm assuming you're using a relational model.  I'd probably create a data item that uses the "extract" function to pull the "month" out of the date, and group by that.  I'd probably have another dataitem called "OnContract" that determines if an employe was on contract on a given date, and has a value of 0 or 1.  Then , we can simply use the automatic aggregation to figure out how many employee's were on contract in any given grouping.
0
 

Author Comment

by:ac_davis2002
ID: 21795004
I am using a relational model yes.

That sounds like what I need.

Are you able to send me any example of the "extract" function?

This is the select statement I can use to extract the infomation for just one month

Select CPCompanyid,NoEmployees as noemp from CTContracts where Fromdate  
<= '20080430' and  EndDate >= '20080401' and CTcontracts.LKContractTypeID in (0,8) Order by CPCompanyid,ctcontractid  

The bit I am struggling with is using this statement in conjunction with the start and end date prompts and moving the dates forward to meet the time scales I need.
0
 

Author Closing Comment

by:ac_davis2002
ID: 31467577
Cheers!
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now