Sunday, 20 May 2018

Creating a custom parameter and using it display dynamic visualizations in Tableau Desktop

Hi,

Before trying this post, let's read how to connect to postgresql database and query the tables in tableau in my previous post. 

Version  used for this exmaple: 2018.1.0

1)  From previous post, let's connect and query foodmart database.
2) Once the query is written navigate to the "Sheet1"(you can rename it as you want)
3) From the Measures section, right click on empty space and then select "Create Parameter..." option as shown in below image.

4) From the popped up "Create Parameter" window specify the parameter name, let's say "paramState" and fill the properties of it, Say type as "String", Current Value as "OR", and from the Allowable values: select "List" and fill manually the values into it.
 


5) Now, edit the custom SQL to provide the created parameter (paramState) to make the query dynamic as shown in below image.
(Click on image to get best view of the content)



6) Now, to show the parameter on the page with single select dropdown option.
    right click on the parameter and then click on "Show Parameter Control" option


This will get the parameter as dropdown on the console


6) Now, pull the fields to the shelfs and play with different values of parameter dropdown.
Output when select "OR" state 

(click on image to get best view of the content)
Output when selected "CA" state



NOTE: 

While exploring this concept, I was thinking whether it is possible to populate the values of parameter from a SQL query results and found below has some alternative approach to do.

https://community.tableau.com/thread/251724


Download the example 
Click here to download .twd file

This example is developed in latest version 2018.1 and not published to tableau server.

- Sadakar Pochampalli

Connecting to PostgreSQL foodmart database and querying tables in Tableau Desktop

Hi,

In this post, you would see how to connect to foodmart database and query the database
from Tableau Desktop

Tableau Version : 2018.1

See below video tutorial (View directly in YouTube with 720p HD quality)

Link : https://www.youtube.com/watch?v=GhGxzfXdlIk




1) Click on Show Start Page once you open the Tableau Desktop
2) From the left side "Connect" pane select Postgresql and then provide the database connection strings in the poped up window as shown in below image.
 

3) Click on Sign In button to navigate to the query designer window.
4) Double click on New Custom SQL from the left side panel to open the "Edit Custom SQL" window.
5) Write below query and click on preview button.

     SELECT  t.the_date,
SUM(sf7.unit_sales) unit_sales,
SUM(sf7.store_sales) store_sales
FROM sales_fact_1997 sf7
LEFT JOIN time_by_day t ON sf7.time_id=t.time_id
LEFT JOIN customer c ON sf7.customer_id=c.customer_id
WHERE t.the_year=2012 AND c.state_province='CA'
GROUP BY t.the_date
ORDER BY t.the_date

This is how you can connect to a database and query it using tableau desktop.

Thank you
Sadakar Pochampalli





Creating a custom parameter and using it display dynamic visualizations in Tableau Desktop

Hi, Before trying this post, let's read how to connect to postgresql database and query the tables in tableau in my previous post.  ...