Hitachi Vantara Pentaho Community Forums
Results 1 to 7 of 7

Thread: Changing date parameter using DateInputComponent not working

  1. #1
    Join Date
    Dec 2012
    Posts
    121

    Default Changing date parameter using DateInputComponent not working

    Hi all,
    i have the same issue on my stuff.
    I have a CDE dashboard with a dateInputComponent which represents a StartDate filter.
    When I change the date, i extract the year and month from it (using the snippet below), so i use it on a mdx query to plot a bar chart.

    The issue is that when i open thedashboardthe first time, it works fine, i.e. the bar chart refresh itself displaying the correct time interval on x-axis.
    Instead, when i change the date Input component other times, year and month parameters not change correctly, but they update to the correct values only if i click on an other filter (or the same StartDate filter) on my dashboard.

    My snippet, used on Preexecution and postChange functions of the Start Date filter (=dateInputcomponent):

    function decode(){
    var data_i=p_start_date.split("-");
    var year = data_i[0]; //the extracted year
    var month = data_i[1]; //the extracted month
    var day = data_i[2];

    Dashboards.fireChange('p_start_year', parseInt(year,10));
    Dashboards.fireChange('p_start_month',parseInt(month,10));

    }

    Obviously, the bar chart has two listeners: p_start_year, p_start_month which i extract from the date.

    Hope i was clear.
    Yamas.

  2. #2
    Join Date
    Dec 2012
    Posts
    121

    Default

    Hi guys,
    i fixed my issue in this way.
    I delete on my chart the listener on p_start_year, p_start_month.
    On the postChange and preExecution i write this code and it works:


    var data_i=p_start_date.split("-");
    var year = data_i[0];
    var month = data_i[1];
    var day = data_i[2];

    var x=Dashboards.getComponent("render_areat_chart"); //i get the object by its name
    Dashboards.update(x); //i update the chart

    Hope this help!!

    Yamas

  3. #3
    Join Date
    Feb 2013
    Posts
    530

    Default

    Hi Very urgent help needed..

    I have done as you gone in my requirement.
    I have start_date and end_date parameters

    For example in my MDX I'm having like this Crossjoin({[DateYYYY].[All].[${start_date}]:[DateYYYY].[All].[${end_date}]}


    I have written in PreExecution like below

    var x=Dashboards.getComponent("line_chart"); //i get the object by its name
    Dashboards.update(x); //i update the chart

    mine is line_chart

    Post change as

    var data_i=start_date.split("-");
    var year = data_i[0];
    var month = data_i[1];
    var day = data_i[2];


    var data_i2=end_date.split("-");
    var year2 = data_i2[0];
    var month2 = data_i2[1];
    var day2 = data_i2[2];

    But I'm not getting any out put ?

    Please help me in this

  4. #4
    Join Date
    Feb 2013
    Posts
    530

    Default

    I need to pass only Year from the parameter.

  5. #5
    Join Date
    Nov 2011
    Posts
    1,229

    Default

    shouldn't you assign the value of year and year2 to the parameter, then ?
    Pedro Vale
    --
    CTools Product Development
    http://www.webdetails.pt

  6. #6
    Join Date
    Jun 2017
    Posts
    1

    Default

    Quote Originally Posted by pamval View Post
    shouldn't you assign the value of year and year2 to the parameter, then ?
    hi i need help with cde dashboard date input coomponent
    i want to extract year,month,day from date input, so i used this code
    var data_i=start_date.split("-");
    var year = data_i[0];
    var month = data_i[1];
    var day = data_i[2];
    var data_i2=end_date.split("-");
    var year2 = data_i2[0];
    var month2 = data_i2[1];
    var day2 = data_i2[2];

    in preExecution of my chart and in the mdx i used [Date].[year].[day] but with no result
    i have two date parametres(param_start and param_end) how can i do this correctly
    can you pllzz help

  7. #7
    Join Date
    Nov 2012
    Posts
    24

    Default

    Create parameters "start_date_mdx" and "end_date_mdx"
    Add this code on the preChange of the date filter:

    function(start, end) {
    dashboard.setParameter("start_date_mdx", moment(start).format('[[Date]].[[]YYYY[]].[[]DD[]]'));
    dashboard.setParameter("end_date_mdx", moment(end).format('[[Date]].[[]YYYY[]].[[]DD[]]'));
    }

    In MDX Query use this parameters as:
    ...
    SET DATEFILTER AS {${start_date_mdx}:${end_date_mdx}}
    ...
    Don't forget to add parameters to be used as part of the query and component using the query


    Miguel Gaspar
    Learning Pentaho CTools
    https://www.packtpub.com/big-data-an...pentaho-ctools

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.