Topic
  • 5 replies
  • Latest Post - ‏2015-02-25T12:46:29Z by lucianadl
vikky440
vikky440
11 Posts

Pinned topic dynamic current year in value prompt

‏2013-06-20T07:55:57Z |

Hi Friends,

 

I have to show dynamic current year in value prompt  , i have tried different ways , able to show dynamic current year but the output is not coming properly,

please give me some idea . thanks

  • rperzul
    rperzul
    62 Posts

    Re: dynamic current year in value prompt

    ‏2013-06-20T15:09:57Z  

    Hi,

    you can achieve this by using the Prompt API (available since Cognos 10.2). You should be able to get the entire Prompt API samples as part of the sample reports and packages that you can install (http://pic.dhe.ibm.com/infocenter/cbi/v10r1m0/index.jsp?topic=%2Fcom.ibm.swg.im.cognos.inst_cr_winux.10.1.0.doc%2Finst_cr_winux_id15018SettingUpSamples.html)

    When looking at the date prompt presets example (http://pic.dhe.ibm.com/infocenter/cbi/v10r2m0/index.jsp?topic=%2Fcom.ibm.swg.ba.cognos.ug_cr_rptstd.10.2.0.doc%2Fc_rs_smples_prompt_api.html) you should be able to adopt this to your value prompt.

    Attached is the spec for this report.

    Hope that helps as starting point.

    Regards,

    Ron

    Attachments

  • Suresh_BI
    Suresh_BI
    21 Posts

    Re: dynamic current year in value prompt

    ‏2013-06-22T05:53:05Z  

    Hi Vikky,

                     You can do it in other way also. Lets say I have 2 queries 1 is Report Query and another one is Prompt Query.

    In Prompt query create new DataItem and write code like case when [Year]=year(current_date) then 1 else 0 end

    Select that Prompt Properties. Select UseValue= This newly created data item and DisplayValue=Ur existing Year DataItem

    and select Default Selections Properties add  "1" in that and select ok.

    In Report Query also create one new DataItem and write above code. in the filter drag this newly created dataitem=?your Year Parameter?.

    this above fitler always filter for current year. when you schedule this report you no need to hard code manually. It will take automatically for current year.

    If you need any info on this please reply.

    Thanks,

    Suresh.

  • vikky440
    vikky440
    11 Posts

    Re: dynamic current year in value prompt

    ‏2013-06-27T13:50:22Z  

    Hi Suresh and Ron,

     

    Its working fine for me , thanks for your help.

     

    Regards,

    Vithal N

  • vikky440
    vikky440
    11 Posts

    Re: dynamic current year in value prompt

    ‏2013-07-03T06:28:22Z  
    • vikky440
    • ‏2013-06-27T13:50:22Z

    Hi Suresh and Ron,

     

    Its working fine for me , thanks for your help.

     

    Regards,

    Vithal N

    Hi Suresh,

    I did as you told , I have data 2013 and 2012 , when I am choosing 2013 , the data is coming fine but when i choose 2012 data is not  at all coming.

    so I need to confirm whether it works with 2012 ?

    Thanks,

    VIK

  • pcog26
    pcog26
    3 Posts

    Re: dynamic current year in value prompt

    ‏2015-01-09T18:47:51Z  
    • vikky440
    • ‏2013-07-03T06:28:22Z

    Hi Suresh,

    I did as you told , I have data 2013 and 2012 , when I am choosing 2013 , the data is coming fine but when i choose 2012 data is not  at all coming.

    so I need to confirm whether it works with 2012 ?

    Thanks,

    VIK

    Hi Vikky,

    I'm not sure how the Suresh logic is working for you , but I think it should not work. Because you have given the newly created data item as use value for a prompt and it would have either 1 (when the current year = [year]) or 0. so, my guess it should not work. I may be wrong here, but if you think it is working for 2013 but 2012 then change the data item as below

    case when [Year]=year(current_date) then 1 else [Year] end

    anyway, you previously mentioned that it is working fine for you. Was it Ron's suggestion working for you or the other?

    I'm looking for javascript to make my value prompts to select by default as current month and current year. so if you find any solution please share it here.

    Thanks in advance