Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in BI by (17.6k points)

I am trying to do sentiment analysis on a table that I have.

I want each row of string data to be passed to the R script, but the problem is that Tableau is accepting only aggregate data as params for:

SCRIPT_STR(

  'output <- .arg1; output', [comments]

)

This gives me an error message:

# All fields must be aggregate or constant. 

1 Answer

0 votes
by (47.2k points)
  • From the Tableau and R Integration documentation:

  • Given that the SCRIPT_*() functions work as table calculations, they require aggregate measures or Tableau parameters to work properly. Aggregate measures include MIN(), MAX(), ATTR(), SUM(), MEDIAN(), and any table calculations or R measures. If you want to use a specific non-aggregated dimension, it needs to be wrapped in an aggregate function.

  • In your case you could do:

SCRIPT_STR( 'output <- .arg1; output', ATTR([comments]) )

  • ATTR() is a special Tableau aggregate that does the following:

IF MIN([Dimension]) = MAX([Dimension]) THEN [Dimension] ELSE * (a special version of Null) END

  • It’s really useful when building visualizations and you’re not sure of the level of detail of data and what’s being sent

  • Note: It can be significantly slower than MIN() or MAX() in large data sets, so once you get confident your results are accurate then you can switch to one of the other functions for performance.

Related questions

0 votes
1 answer
asked Jul 23, 2019 in BI by Vaibhav Ameta (17.6k points)
0 votes
1 answer

Browse Categories

...