COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: mmckeen1 on 09 Feb 2010 07:56:42 AM

Title: How to get YTD, QTD, MTD in a crosstab
Post by: mmckeen1 on 09 Feb 2010 07:56:42 AM
I need to create a crosstab report that will be scheduled to run on a weekly basis.  My client wants to see the results rolled up in columns for month to date, quarter to date, and year to date.  I've tried to write a data item using the following expression for 'month to date:'

if ([Time Period] >=  _first_of_month(current_date)) then ([Count]) else (null)

However, I cannot get it to work.  I'm getting the following errors when I go to validate the query:

GEN-ERR-0016 The 'fn:current_date' function is not supported in the context in which it is used.
GEN-ERR-0009 Data source type(s) '' - Function 'realDataMode' is not supported in 'NoDataModeProvider'.
GEN-ERR-0011 The pattern 'manyDimensions' is not supported in 'RelationalQueryProvider'.
GEN-ERR-0009 Data source type(s) '' - Function 'manyDimensions' is not supported in 'TabularOperationProvider'.

My package is relational, and I'm using Cognos 8.4.  Any help would be appreciated, thanks.
Title: Re: How to get YTD, QTD, MTD in a crosstab
Post by: blom0344 on 09 Feb 2010 10:07:49 AM
My favorite alternative it to create 3 seperate queries and union them into a fourth, like:


SELECT '1.MTD',...........................
FROM ......
WHERE << add specific filter>>
union all
SELECT '2.QTD',...........................
FROM ......
WHERE << add specific filter>>
union all
SELECT '3.YTD',...........................
FROM ......
WHERE << add specific filter>>



For this to work you need to make sure that total aggregate is set for the measures in the union.
By taking the dataitem that stores '1.MTD' / '2.QTD' / '3.YTD' as dimension in the crosstab you can automatically create the 3 diverse columns
Title: Re: How to get YTD, QTD, MTD in a crosstab
Post by: Sreeni P on 09 Feb 2010 11:03:37 AM
Quote from: blom0344 on 09 Feb 2010 10:07:49 AM
My favorite alternative it to create 3 seperate queries and union them into a fourth, like:


SELECT '1.MTD',...........................
FROM ......
WHERE << add specific filter>>
union all
SELECT '2.QTD',...........................
FROM ......
WHERE << add specific filter>>
union all
SELECT '3.YTD',...........................
FROM ......
WHERE << add specific filter>>



For this to work you need to make sure that total aggregate is set for the measures in the union.
By taking the dataitem that stores '1.MTD' / '2.QTD' / '3.YTD' as dimension in the crosstab you can automatically create the 3 diverse columns


Hi blom,

u did such a good job, but thing is plz....explain in detail taking any example, then people will know and understand of their level best...(guess it takes bit more time but it is help full )
Title: Re: How to get YTD, QTD, MTD in a crosstab
Post by: blom0344 on 09 Feb 2010 02:05:11 PM
Okay, let me try a different perspective..

The trick is to keep the crosstab design as simple as possible.


In the simplest form (structure) this will yield:

                                 |McGuffin
-----------------------|----------------
[Someotherdimension]   | [count]


With data from the videostore:

                                 |1.MTD     |2.QTD    |3.YTD
-----------------------|---------------------------
Apocalypse Now           |30           |70         |147
Strangers on a train      |2             |7           |11
Avatar                        |4500        |8960      |32490

*sorry for mentioning a videostore, my gen. still not 100% adjusted to downloading   ;D