COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: velniaszs on 11 Dec 2013 08:51:14 AM

Title: Style variables in Multidimensional report
Post by: velniaszs on 11 Dec 2013 08:51:14 AM
Hello,
I am starting to work with multidimensional reports.
My report which has a prompt that is linked to boolean style variable [Query2].[Day_Calc]<>ParamDisplayValue('prompt') that is changing box type to none if condition is met.
Is there a way of adding default value to current_date?
Title: Re: Style variables in Multidimensional report
Post by: velniaszs on 11 Dec 2013 09:06:23 AM
here is the report.

I also have tried to use variable but the highlited part seems not to be working:

( ParamDisplayValue('prompt') is null
and [Query2].[Current_Date]<>[Query2].[Day_Calc] )   OR
(ParamDisplayValue('prompt') is not null
and[Query2].[Day_Calc]<>ParamDisplayValue('prompt'))
Title: Re: Style variables in Multidimensional report
Post by: navissar on 11 Dec 2013 01:53:42 PM
Right, if I understand correctly what you have done here, it's no wonder it takes longer.
You're bringing in all records, and then have Cognos run over the HTML and hide the records you don't wish to see.
When you're using a filter function or a slicer, you limit the number of records pulled, which is faster. The more records you pull, the longer the query will take.
Title: Re: Style variables in Multidimensional report
Post by: velniaszs on 12 Dec 2013 03:12:45 AM
Yes you are right this is exactly what my report does.
The problem with filter or slicer or style variable I can't figure out how to add current_date as a default as in the prompt the default value is static field, and current date is dynamic.
Title: Re: Style variables in Multidimensional report
Post by: navissar on 12 Dec 2013 05:00:35 AM
Well, that's a whole new topic.
There are several ways you can go about adding current_date as your default prompt selection. I see you're using a value prompt, so you can add a static value and set you slicer so that if the static value is selected it would slice by current_date. There are several ways to achieve this, and they depend on your cube structure and/or your cube vendor.
Another, cooler option is to use JavaScript to select the date that matches today's date.
I'm attaching a 10.2 (I believe that's the version you're using) sample for JS solution (It's based on samples and therefore addresses month, but you should be able to find your way through changing it to match your case. Also, I did not use the Prompts API in this case, although it's possible, b/c calculating the MUN for use value is a pain).

Good luck!
Title: Re: Style variables in Multidimensional report
Post by: velniaszs on 12 Dec 2013 05:20:07 AM
This will be very usefull in other projects but for this project the cube will be rebuilt each week so the current day value will never show today() so JS would not work here.

In my date dimension in cube I have current day.
Could you show example of filter/slicer that would filter the date, but default it to current_date?
I have uploaded my cube Date dimension diagram
Title: Re: Style variables in Multidimensional report
Post by: navissar on 12 Dec 2013 05:50:09 AM
Cool, you have a Current Day hierarchy. That simplifies things.
Try the following:
Create your prompt as you would usually, with all dates.
Then, create your date member like this:
#prompt('monthPrm','memberUniqueName','firstChild([MUN].[of].[current day].[root])')#.
This will insert the value of the prompt to the data item, however, the default value will be the first child of the root member in the current day hierarchy, which is basically current day.
Attached a sample using months.
Title: Re: Style variables in Multidimensional report
Post by: velniaszs on 12 Dec 2013 07:07:11 AM
Oh this is briliant. Worked perfectly! Thank You!
Title: Re: Style variables in Multidimensional report
Post by: navissar on 12 Dec 2013 08:38:18 AM
Happy to help.