I have Date,product,Quantity_Sold columns and I want
Product, MTD(month Till date),YTD(Year Till Date) as output.


Can anyone help me with the logic in getting MTD i.e
quantity sold from 1st of this month to till date (i.e. 01-
11-2013 to 26-11-2013) and YTD i.e QTD sold from 1st date
of the year to till date(i.e. 01-01-2013 to 26-11-2013).


Sample output model:

Product MTD YTD



I have Date,product,Quantity_Sold columns and I want Product, MTD(month Till date),YTD(Year Till D..

Answer / naresh

HI All,
Follow below steps to achieve this

1) In Filter condition place the below condition (to_char([START_DATE],'YYYY')=to_char({sysdate},'YYYY') and [START_DATE] <= {sysdate})

2)Create one Derived colum as MTD and in Expression use below code

case when (to_char([START_DATE],'MM')=to_char({sysdate},'MM') and [START_DATE] <= {sysdate})
then [Quantiry] end

Next in properties if this column for aggrigate Function and for Rollup Aggrigate Function change 'automatic ' to 'None'.
3) create one more Derived column as YTD and in expression use below code
case when (to_char([START_DATE],'YYYY')=to_char({sysdate},'YYYY') and [START_DATE] <= {sysdate})
then [Quantity] end

here sysdate is oracle date function.

Thats it .

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Cognos Interview Questions

how to do page breaks in cognos 8 Report studio pls give the navigation

4 Answers  


diff b/w grouping and aggregation

1 Answers   HCL,


i have 4 countries in my database as USA, UK, INDIA, CHANA. In value prompt's prompt control list, i want WESTERN_COUNTRIES, ASIAN_COUNTRIES instead of those country names. When i click on WESTERN_COUNTRIES, it should retrieve USA, UK records and when i click on ASIAN_COUNTRIES, it should retrieve INDIA, CHINA records. How is it possible?

4 Answers   Tech Mahindra,


For example I developed some reports on employee package now I have to develop same reports to another package.How can I change reports to another package?

5 Answers   TCS,


How to hide/unhide the prompts which are not used by unauthorized users?

3 Answers  






what is prompt variable

2 Answers   HCL,


Can we create reports using OLTP database?How?

3 Answers  


What is called Cognos powerplay?

0 Answers  


15. If I select the current month and year how can we display previous 11 months data?

2 Answers   TCS,


Tell me about Schemas?

4 Answers  


Give me any example of semi and non additive measures?

0 Answers  


In one of my report i have one data item sales_amount. If this report is run by one user from india so the sales_amount should be display in indian repees(Rs.) format, if USA user then in dollers($), if UK user then In Pounds.Hou can i achive this? Please answer me.

4 Answers   Accenture, HCL, IBM,


Categories