1 Reply Latest reply on Dec 29, 2016 2:04 AM by Bora Beran

    R and Tableau integration: make view reactive on dimensions

    Pieter Krsteff-Jantcheff

      I am using Tableau integration with R to visualize some time series using the `rollapply` function in R. This function takes 2 inputs (arg1 and arg2). The current view is below. The calculation I use is the following:

       

       

          SCRIPT_REAL(

          'library(zoo);

          win <- rollapply(.arg1,width=.arg2[1], by=.arg3[1], FUN=mean,partial=T);

          vector <- rep(NA,3644);

          vector[1:length(win)] <- win;

          vector;

          ',

          SUM(FLOAT(TRIM([Model Root/BusSystems/CANopen/dSPACE_Read_Data/Input_Motor/Inverter_Temperature/Out]))),

          [Window parameter],

          [Window parameter 2]

          )

       

      Tableau.png

       

      Calculation 4 measures the length of the vector created in calculation 3. Now I want to make calculation 3 reactive to the chosen dimension. Therefore I created a parameter 'Dimension', with 2 randomly chosen dimensions in the view. When a different dimension is chosen by the user, a the time series line of this dimension should appear. I tried:

       

       

          SCRIPT_REAL(

          'library(zoo);

          win <- rollapply(.arg1,width=.arg2[1], by=.arg3[1], FUN=mean,partial=T);

          vector <- rep(NA,3644);

          vector[1:length(win)] <- win;

          vector;

          ',

          SUM(FLOAT(TRIM(.arg3))),

          [Window parameter],

          [Window parameter 2],

          [Dimension]

          )

       

       

      But in this case nothing happens. So basically I would like to know how to make the time series that is displayed reactive on the selected dimension. Thanks!

        • 1. Re: R and Tableau integration: make view reactive on dimensions
          Bora Beran

          So you would like the first argument to rollapply to change based on what user selects from Dimension drop down?

           

          If that's the case wouldn't .arg1 need to be replaced by .arg4?

           

          Once you do that you can create a parameter named DimensionDropDown that has the names of fields you want to display.

           

          Then write your Dimension calculation in the form

           

          IF DimensionDropDown = 'Some Selection from drop down'

          then sales

          Elseif DimensionDropDown = 'Another Selection from drop down'

          then profit

          end

           

          So when user selects something from drop down it would return a different measure e.g. sales or profit in the mock example above.