COGNOiSe.com - The IBM Cognos Community

IBM Cognos Analytics Platform => Cognos Analytics => Reporting => Topic started by: tushar gaurav on 27 May 2022 12:25:31 AM

Title: How to render two different object using date prompt
Post by: tushar gaurav on 27 May 2022 12:25:31 AM
Hi,

I have a date prompt in the report page itself.
I have two singleton where I need to display First of the month of report run date in first singleton(Singleton1)
and Report run date in second singleton(Singleton2).
Singleton1 should be displayed if First of the month is selected and Singleton2 should be displayed for any other dates.
For example
Scenario 1:if the report run date is 27 may 2022 and from the date prompt 1 may 2022 is selected then singleton 1 showing 1May2022 should be displayed.
Scenario 2:if the report run date is 27 may 2022 and from the date prompt 15 may 2022 is selected then singleton2 showing 27May2022 should be displayed.


Can you please help me in this scenario.

Thanks,
Tushar
Title: Re: How to render two different object using date prompt
Post by: oscarca on 27 May 2022 03:05:31 AM
I misunderstood
Title: Re: How to render two different object using date prompt
Post by: tushar gaurav on 27 May 2022 04:24:55 AM
Hi Oscarca,

Thanks for your response.
I have modified the query for easy understanding.
If possible can you please help me with the solution.

Thanks,
Tushar
Title: Re: How to render two different object using date prompt
Post by: oscarca on 27 May 2022 04:54:26 AM
I solved it like this:
Created two data items:
[pDate] = #prompt('pDate','MUN','','')#
[firstOfMonth] = _first_of_month(cast(caption([p_date]) as date))

Create a boolean variable:
vFirstOfMonth = string2date(substring(ParamDisplayValue('pDate'),1,10)) = [Query2].[firstOfMonth]

Then add the render variable to the singelton that should show First of Month.

Repeat the same procedure for the second singleton and write the variable something like this:
vSeconds = string2date(substring(ParamDisplayValue('pDate'),1,10)) <> [Query2].[firstOfMonth]

In your case it might look a little different depending if your report is based on a cube or relational data
Title: Re: How to render two different object using date prompt
Post by: oscarca on 27 May 2022 05:24:59 AM
Its even more simple with relational data:
Data item : [firstOfMonth] = cast(_first_of_month([C].[C_Sales_Details].[Dim_Calendar].[Date_1]) as date)
Layout Calculation: ReportDate() or Data item : current_date
vFirstOfMonth: string2date(substring(ParamValue('pDate'),1,10)) = [Query1].[firstOfMonth]
vOther: string2date(substring(ParamValue('pDate'),1,10)) <> [Query1].[firstOfMonth]

place the vFirstOfMonth render variable on the first singleton and vOther on the second singleton/or Layout calculation
Title: Re: How to render two different object using date prompt
Post by: tushar gaurav on 27 May 2022 06:50:15 AM
Thanks a lot for your help :) :)