IcCube report on selected dates in date slicer
There is another option that doesn't need javascript and will most likely live longer. Range selection can use values ββfrom MDX, so we can modify the query to get what we are looking for:
WITH
SET [dates] as [Time].[Calendar].[Day].allmembers
Function ic3Min() as Head([dates])
Function ic3Max() as Tail([dates])
Function ic3DefFrom() as Tail([dates]).dtWithDayOfMonth(1) // first day of month , not the same as withDayOfMonth
Function ic3DefTo() as Tail([dates])
SELECT
{ic3Min(),ic3Max(),ic3DefFrom(),ic3DefTo()} on 0
FROM [Sales]
CELL PROPERTIES CELL_ORDINAL
You have a wonderful family of date functions in MDX that allow you to navigate through the time. In our example, LookupByKey , Today and withDayOfMonth . Something like
[Time].[Calendar].[Day].lookupByKey( Today()->withDayOfMonth(1) )
This can be converted to a function to be reused:
Function myDatesStartOfCurrentMonth() as [Time].[Calendar].[Day].lookupByKey(Today()->withDayOfMonth(1) )
Eventually, you must change the filter to use the MDX values:
And this must happen.
source to share
There is no way to set such a preselection with existing data parameters, but you can achieve the desired behavior with JavaScript Hooks Widget .
To preselect on the first day of the month:
- Setting data parameters
eg. As in the screenshot above, but without prior selection
-
Go to the category of widget categories
-
Copy the below code to the "On Data Received" value:
In the received data (for icCube 6.1):
/**
* Return data object
*/
function(context, data, $box) {
context.fireEvent('initDate', {caption_: moment().set('date', 1).format('YYYY-MM-DD')})
return data;
}
In the received data (for earlier versions):
/**
* Return data object
*/
function(context, data, $box) {
context.eventMgr().fireEvent('initDate', {caption_: moment().set('date', 1).format('YYYY-MM-DD')})
return data;
}
- Configure the events section as follows:
Range preselection update
To apply the preselection selection range, the JavaScript body in the On Data Received hook:
/**
* Return data object
*/
function(context, data, $box) {
let event = new viz.event.RangeSelectionEvent([
{name: moment().set('date', 1).format('YYYY-MM-DD')},
{name: moment().set('date', 2).format('YYYY-MM-DD')}
]);
context.fireEvent('initDate2', event)
return data;
}
PS Check the Demo report to see how it works.
source to share