Search code examples
iccubeiccube-reporting

IcCube reporting preselected dates in date slicer


what can i put in the 'Preselection from' label to get the beginning of current month?

enter image description here


Solution

  • There is another option that doesn't need javascript and most probably will live longer. The Range selection can use values from the MDX so we can change query to get what we're 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've a nice family of date functions in MDX that allow for navigating time. In our example , LookupByKey,Today and withDayOfMonth. Something like

    [Time].[Calendar].[Day].lookupByKey( Today()->withDayOfMonth(1) )
    

    That could be transformed into a function to be reused :

     Function  myDatesStartOfCurrentMonth() as [Time].[Calendar].[Day].lookupByKey(Today()->withDayOfMonth(1) )
    

    Eventually you've to change the filter to use the MDX values :

    enter image description here

    And that should make it.