COGNOiSe.com - The IBM Cognos Community

IBM Cognos Analytics Platform => Cognos Analytics => Reporting => Topic started by: peewan on 20 Jan 2020 12:15:59 PM

Title: Label for month of the year
Post by: peewan on 20 Jan 2020 12:15:59 PM
   Month 1   Month 2   Month 3   Month 4   Month 5   Month 6   Month 7   Month 8   Month 9   Month 10   Month 11   Month 12
Visits   2   3               5               2              0               1              6              7                1               3              3               1


The report is running my prompt date.
Month 1 = Minimum month/year by Prompt date
Month 2 = add_month (Month1, 1)
Month 3 = add_month (Month1, 2)
...

I would like to have Label 'Month' populate by actual 'MonthYear'.

For example:

If the prompt; 03/2019 to 02/2020
Month 1 = 03/2019 data = will display 'March 2019' or '032019' in the label of the report
Month 2= 04/2019 data = 'April 2019'

I can't do if or case statement: Month 1 in Jan 2019 then 'Jan2019', because the prompt date is different any time/year

Thank you

Title: Re: Label for month of the year
Post by: Cognos_Jan2017 on 21 Jan 2020 01:32:22 PM
Make two new Data Items, where your Parameter for your Prompt may be "TheMonthYear"

This assumes the DB you are using has Left and Mid functions.
Data Item AAA ...
Left(?TheMonthYear?,2)

Data Item BBB ...
Mid(?TheMonthYear?,3,4)

You can add a Text, make it a Report Expression of ...
AAA+'/'+BBB
... then add that to your Report.

HTH, Bob
Title: Re: Label for month of the year
Post by: Cognos_Jan2017 on 21 Jan 2020 03:44:45 PM
Looking at your label again of ... 03/2019 to 02/2020

You will need ...
Data Item BBB ...
Mid(?TheMonthYear?,4,4)
Title: Re: Label for month of the year
Post by: peewan on 23 Jan 2020 05:01:09 PM
Quote from: Cognos_Jan2017 on 21 Jan 2020 01:32:22 PM
Make two new Data Items, where your Parameter for your Prompt may be "TheMonthYear"

This assumes the DB you are using has Left and Mid functions.
Data Item AAA ...
Left(?TheMonthYear?,2)

Data Item BBB ...
Mid(?TheMonthYear?,3,4)

You can add a Text, make it a Report Expression of ...
AAA+'/'+BBB
... then add that to your Report.

HTH, Bob

It did not work for replacing LABEL NAME by prompt or I miss understanding?!

I just created the new data items with extract month, and date from [prompt date], but where do I apply it to replace my old label?

Title: Re: Label for month of the year
Post by: Cognos_Jan2017 on 24 Jan 2020 03:12:58 AM
Is your prompt result, IE ... 03/2019 to 02/2020 ?

If it is, that is from the parameter you defined.  If your define parameter, IE, is ?LMN?

Then write Left(?LMN?,2) as a Data Item in your query.  For this example, Left(?LMN?,2) would result as 03.

Do the same with the Mid(?LMN?,4,4) resulting in 2019.

Let me know if that helps.  TIA, Bob