Reporting on activity by week

This is a rewrite of this post as i completely failed to understand what i’d written. The original text is left after the break for completeness.

A week is a unit of time that has to be derived, and therefore has multiple meanings. Some business will run Monday to Friday, others will run Sunday to Saturday. To calculate the week, you need to know what date the first day of that week occurred on. This is actually quite easy to derive as you will know what day of the week the current day is. If you are running a Monday – Sunday week then if today is Tuesday, it is day 2 of the week, therefore the date the week starts will be 1 day ago. If the day is Thursday, this will be day 4 of the week, therefore the date teh week starts will be 3 days ago.

To achieve this is Cognos Report Studio we will use two funcitons.

The first function is

_day_of_week ( date_expression, integer )

The first parameter is the date you want to know the day of week of. The second paramater is the day that starts the week. 1 = Monday, 2 = Tuesday, etc. So in this case we will use the value 1. This will return the day of the week.

The second function is

_add_days ( date_expression, integer_expression )
This take the first parameter, and adds to it the number of days sepcified in the second. If you prefix the second paramater with a minus (-) then it will remove that number of days.

So to work out the week number, we need to take the

Day of the week, and remove that many days from the current date. However  as the first day of the week is day 1, and not day 0. So to compensate for this we need to add another day on.

The final formula would be
_add_days(cast([Transaction Date],date),-_day_of_week([Transaction Date],1)+1)


Minimum date in Cognos Report Studio

I have a list containing

[Customer ID]
[Transaction ID]
[Transaction Date]
[Sales Team Name]
[Purchase Type]

I want to have a list that gives me the date of earliest transaction for each customer. Filtering the report on:
[Transaction Date] = minimum ([Transaction Date] for [Customer ID])
will give me the earliest date the customer had a transaction.
The only issue with this is where the customer has two transactions on their first day. That’s the bit i’m working on. Any help or advice would be greatly appreciated.


Converting YYYY-MM-DD to YYYYMMDD in Cognos Report Studio

How to convert standard SQL date format to YYYYMMDD

right(year([Gym].[Member Details].[DOB]),4)+
right(month([Gym].[Member Details].[DOB])+100,2)+
right(day([Gym].[Member Details].[DOB])+100,2)

Resizing value prompt boxes in Cognos Report Studio

Thanks to the following site for the follwoing.

To resize a value prompt insert a snippet of html before it with the following


Then another html snippet afterwards with the code below


var e=document.getElementById('selectSearch');
var myselect = e.getElementsByTagName('select')[0];

This will then resize the element automatically within the page (just don’t ask me how)