If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

Dynamic current Month selection

Started by srinu_anu2007, 18 Feb 2014 04:34:50 AM

Previous topic - Next topic

navissar

Hi Srinu,
Let's put some context here. In the solution I offered, I specifically wrote it would be better to use static choices for the month prompt, so you don't need a month query.
Quote from: Nimrod Avissar on 13 Mar 2014 04:59:41 AM
Change your month prompt: remove the query it is attached to and set static choices like so: "Jan","Feb","Mar" and so on. Make sure use and display values are the same. See screenshot attached.
Now, if you tried my solution and it doesn't work, please let me know what specifically didn't work. If you haven't yet tried my solution, I suggest you do - at least it would give this a direction. If this is a new requirement for another report, I suggest you start a new thread with it, so as to avoid confusion.

srinu_anu2007

Hi Nimrod,

What ever you provided the solution it's working perfectly but my user wants to set in report page itself so finally we got  it and its working perfectly. JS for current year: <script type="text/javascript">

var form = getFormWarpRequest();
var list = form._oLstChoicesYear_Prompt;
var flag;
var currentYear = new Date().getFullYear();

function defaultYearSelection()
{
   for (i = 0; i < list.length; i++)
   {
      if( list.options.value == currentYear)
      {
           list.options.selected =true;
           flag=i;
           break;
      }   
   }
}

function userYearSelection()
{
   for (i = 0; i < list.length; i++)
   {
      if (list.options.selected)    
      {
          list.options.selected =true;
          break;
      }
   }
}

if (flag == undefined)
{
   defaultYearSelection();
   setTimeout('oCV' + preFix + '.promptAction(\'finish\')', 10);
}
else
{
   userYearSelection();
}


</script>

and for MOnth JS: <script type="text/javascript">

var form = getFormWarpRequest();
var listMonth = form._oLstChoicesMonth_Prompt;
var flag1;
var Months=new Array(12);
Months[0]="Jan";
Months[1]="Feb";
Months[2]="Mar";
Months[3]="Apr";
Months[4]="May";
Months[5]="Jun";
Months[6]="Jul";
Months[7]="Aug";
Months[8]="Sep";
Months[9]="Oct";
Months[10]="Nov";
Months[11]="Dec";
var currentMonth = new Date().getMonth();

function defaultMonthSelection()
{
   for (i = 0; i < listMonth.length; i++)
   {
      if( listMonth.options.text == Months[currentMonth])
      {
           listMonth.options.selected =true;
           flag1=i;
           break;   
      }   
   }
}

function userMonthSelection()
{
   for (i = 0; i < listMonth.length; i++)
   {
      if (listMonth.options.selected)    
      {
          listMonth.options.selected =true;   
          break;   
      }
   }
}


if (flag1 == undefined)
{
                     defaultMonthSelection();
   setTimeout('oCV' + preFix + '.promptAction(\'finish\')', 10);
}
else
{
   userMonthSelection();

}


</script>

Quarter JS: <script type="text/javascript">

var form = getFormWarpRequest();
var listMonth = form._oLstChoicesQuarter_Prompt;
var flag1;
var Months=new Array(12);
Months[0]="Q1";
Months[1]="Q1";
Months[2]="Q1";
Months[3]="Q2";
Months[4]="Q2";
Months[5]="Q2";
Months[6]="Q3";
Months[7]="Q3";
Months[8]="Q3";
Months[9]="Q4";
Months[10]="Q4";
Months[11]="Q4";
var currentMonth = new Date().getMonth();

function defaultMonthSelection()
{
   for (i = 0; i < listMonth.length; i++)
   {
      if( listMonth.options.text == Months[currentMonth])
      {
           listMonth.options.selected =true;
           flag1=i;
           break;   
      }   
   }
}

function userMonthSelection()
{
   for (i = 0; i < listMonth.length; i++)
   {
      if (listMonth.options.selected)    
      {
          listMonth.options.selected =true;   
          break;   
      }
   }
}


if (flag1 == undefined)
{
                     defaultMonthSelection();
   setTimeout('oCV' + preFix + '.promptAction(\'finish\')', 10);
}
else
{
   userMonthSelection();

}


</script>

using those JS iam getting dynamic defaults for current year(2014) and month(Mar) and Quarter(Q1)

1.for getting current year last 2 years i have used your expression.
2. for getting current month, i have used the filter in my month query is :caption([periods])=?Year_P? and this is for optional
3. for getting previous 7 quarters we have used this filter and optional:[Index] <=?Param_Month?  and [Index] > (?Param_Month?)-21

Thanks for one and all and especially for Nimrod.


cognostechie

Maybe I saw this post too late.. It sure went too far and lot of valuable forum members made significant contributions with so much dedication and patience !

Not sure if the OP has an option to do this in the model but I always prefer to do this type of thing in the model
itself. Some time back I posted lot of relative time categories including what is required by the OP and those
work with the DMR also.  That post should still be on the forum somewhere.

The fact that DMR is OLAP over relational made me think about doing it this way. Instead of reading the
data from relational format and restructuring it into OLAP and then cutting it in the report, my idea was to cut it before DMR gets that data so no performance issues. 

By doing this in the model, it is also possible to drill down on those last few quarters ! 


Chandrasekar


Hi Nimrod Avissar,

Actually she wants, value prompt need to select current month-using default selection.

Hi Srinu,

Are you get the solution from this. If you get the solution please tell me. I am also having same problem.

Thanks & Regards,
Chandrasekar.

navissar

Quote from: Chandrasekar on 15 Jul 2014 11:41:24 AM
Hi Nimrod Avissar,

Actually she wants, value prompt need to select current month-using default selection.


1. This is a monster-thread as it is. If you need help, I suggest you open a new thread.
2. You will have to be more specific regarding your requirements in the new thread.

Chandrasekar

Hi Nimrod Avissar,

I need to select current month is a default selection in the value prompt. Using dimensional model.

MUN is [SalesReporting].[Month].[Month]->:[TM].[Month].[Month].[@MEMBER].[FY]

Thamks & Regards,
Chandrasekar

MFGF

Quote from: Chandrasekar on 15 Jul 2014 11:20:18 PM
Hi Nimrod Avissar,

I need to select current month is a default selection in the value prompt. Using dimensional model.

MUN is [SalesReporting].[Month].[Month]->:[TM].[Month].[Month].[@MEMBER].[FY]

Thamks & Regards,
Chandrasekar

Hmmmm.

Nimrod suggested two things:

Quote from: Nimrod Avissar on 15 Jul 2014 03:27:31 PM
1. If you need help, I suggest you open a new thread.

and

Quote from: Nimrod Avissar on 15 Jul 2014 03:27:31 PM
2. You will have to be more specific regarding your requirements in the new thread.

You don't appear to have listened to either of these suggestions.

MF.
Meep!

navissar