So I'm under the impression that with JS in html you can do a dynamic parameter in Tableau. Here is my code:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="http://public.tableau.com/javascripts/api/tableau-2.0.0.min.js"></script>
<script>
$(function() {
var url = 'points to dashboard url';
var vizOptions = {
showTabs : true,
hideToolbar : true,
width : "420px",
height : "420px"
};
currentViz = new tableauSoftware.Viz(document.getElementById('viz'), url, vizOptions);
currentViz.addEventListener(tableauSoftware.TableauEventName.FILTER_CHANGE, onFilterChange);
});
function onFilterChange(e)
{
if (e.getFieldName() == 'Department') {
e.getFilterAsync().then(function(filter) {
var values = filter.getAppliedValues();
var value = values[0]['value'];
// Value of the parameter if "All" is selected in the filter.
if (values.length > 1) {
value = 'All';
}
currentViz.getWorkbook().changeParameterValueAsync('Parameter1', value);
});
}
}
This code I got from https://www.interworks.com/blog/daustin/2015/12/17/dynamic-parameters-tableau and looks pretty plug and play. However, my parameters results are not changing. Note, possible cause for this is that the parameter is actually integer and a list, unlike the tutorial.
Any insight as to the problem?