Skip to content

Instantly share code, notes, and snippets.

@cryocaustik
Last active May 19, 2020 07:38
Show Gist options
  • Save cryocaustik/c24a771d5713e65698065810b1f38d6e to your computer and use it in GitHub Desktop.
Save cryocaustik/c24a771d5713e65698065810b1f38d6e to your computer and use it in GitHub Desktop.
Description for Tableau Parameter Refresh on Workbook Open Failing proof of concept

Parameter Refresh on Workbook Open Failing

Proof of concept to show the parameter will refresh on opening in Desktop or Web-Authoring but fails when used as a regular workbook on a server.

Steps to Recreate

This workbook uses the TableauServerUser value to pass the username to MySQL and retrieve data allocated to the user. In order to recreate this issue, you will need to pass a user value registered in the Tableau (‘Aleksandr.Skobelev’, ‘John.Smith’, or ‘Jane.Doe’).

  1. Create a data connection (DC1) as a Tableau Extract
  2. Create another data connection (DC2) as live
  3. Create parameter to select Region based on values brought back by DC2 and set to auto refresh when workbook opens
  4. Create a visualization from DC1, using the parameter as a filter
    • Example:
      • Create calculated field named “Fltr Region” with logic of:
        • [Region] == [Parameters].[Region]
      • Use calculated field as filter and allow only TRUE values
  5. Verify Parameter refreshes and shows option when closing and reopening the workbook
  6. Publish Workbook to Server
  7. Open Dashboard in Tableau Server
  8. Verify Parameter does not refresh and shows blank value
  9. With the dashboard open in Tableau Server, click “Edit” to enter Web-Authoring
  10. Verify Parameter refreshes and shows options

Sample Data used in MySQL

-- create base tables with sample data
CREATE TABLE IF NOT EXISTS tableau_pub.regions (
  id INT NOT NULL, 
  region VARCHAR(200) NOT NULL,
  created_at DATETIME NOT NULL,
  modified_at DATETIME NOT NULL
);
  
INSERT INTO tableau_pub.regions VALUES
    (1, 'Africa', NOW(), NOW()),
    (2, 'Asia', NOW(), NOW()),
    (3, 'Europe', NOW(), NOW()),
    (4, 'Middle East', NOW(), NOW()),
    (5, 'Ocenia', NOW(), NOW()),
    (6, 'The Americas', NOW(), NOW())
; 
  
CREATE TABLE IF NOT EXISTS tableau_pub.user_mapping (
  id INT NOT NULL,
  user_name VARCHAR(200) NOT NULL,
  region_id INT NOT NULL,
  created_at DATETIME NOT NULL,
  modified_at DATETIME NOT NULL
);
  
INSERT INTO user_mapping VALUES  
    (1, 'Aleksandr.Skobelev', -99, NOW(), NOW()),
    (2, 'John.Smith', 1, NOW(), NOW()),
    (3, 'Jane.Doe', 3, NOW(), NOW())
;

-- Initial SQL for data connection to populate Region parameter
DROP TABLE IF EXISTS user;
  
CREATE TABLE IF NOT EXISTS user AS (
    select  
        um.user_name,
        um.region_id,
        r.region
    from tableau_pub.user_mapping as um
        inner join tableau_pub.regions as r on r.id = um.region_id
            or um.region_id = -99
    where
        um.user_name = [TableauServerUser]
);

-- Custom SQL Query to populate Region Parameter
select * from tableau_pub.user

GitHub Gist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment