admin管理员组

文章数量:1302404

I have created a dashboard in tableau where I have 2 data sources with the same fields. I want to change the data sources using user input from a dropdown list. How can I change the data sources without creating new dashboards. Just like how I can manually replace the data source while developing dashboards in tableau.

Data Sources

I have these 2 data sources and the have the same fields.

Input Parameter

I want to take the input to switch between the data sources from this parameter.

I have tried to search for a solution everywhere but couldn't find anything that worked for me.

I have created a dashboard in tableau where I have 2 data sources with the same fields. I want to change the data sources using user input from a dropdown list. How can I change the data sources without creating new dashboards. Just like how I can manually replace the data source while developing dashboards in tableau.

Data Sources

I have these 2 data sources and the have the same fields.

Input Parameter

I want to take the input to switch between the data sources from this parameter.

I have tried to search for a solution everywhere but couldn't find anything that worked for me.

Share edited Feb 11 at 11:43 DarkBee 15.6k8 gold badges72 silver badges116 bronze badges asked Feb 11 at 10:12 Kshitij KhandelwalKshitij Khandelwal 134 bronze badges 2
  • Try using the "Replace Data Source" option from any Sheet , this might help – Debayan Commented Feb 12 at 5:43
  • @Debayan I know that I can use the replace data souce option, but how can I use it so that the user can change the data source themselves from the list shown in the second image. I can't find a way to do that. – Kshitij Khandelwal Commented Feb 12 at 5:52
Add a comment  | 

3 Answers 3

Reset to default 1

One alternative to try rather than using two different data sources -- UNION the two tables and create a simple boolean calculated field to filter to only the rows that came from the appropriate original table based on the parameter setting. Say called, [Source_Matches?] defined as [Table Name] = [My Table Name Parameter]

Then you can put [Source_Matches?] on the filter shelf, only include rows where [Source_Matches?] is True, and then use the parameter to switch between showing, say Test and Real data or whatever your variations are.

Note string parameters can have a list of acceptable values, each of which has a "Display as" alias. So if your table names are complex, you can still allow your users to see and choose between more meaningful short descriptors.

This should work even if your tables come from different connections thanks to Tableau's federated queries. Of course if you have many separate data tables in each source, you'll have to make multiple unions -- although you might be able to share some of the same dimension and lookup tables.

Note, this approach will likely be slower for very large tables, but fine on small to medium ones — unless your database query optimizer is smart enough to simplify the query to just pull from one table. Test to know for sure. It would be even simpler if Tableau someday allowed supplying a table name by a parameter in custom SQL.

Make two sheets that connect to each data source, place both in a container on your dashboard. Use a Dynamic Visibility Zone to switch the sheets depending on the user parameter. You cannot have a single sheet change the data source with a parameter but this gives you the same effect.

One ad hoc solution to this is to show and hide each dataset on the dashboard via actions.

You will need to create multiple sheets (for Dataset 1 and for Dataset 2). Also create a sheet for dataset 1 and dataset 2 where the user can click and a dashboard action be executed. Those will be what the user selects to run the action (see pictures for example). Initial Dashboard Layout

Once your dashboard has been laid out, go ahead and add your actions. (see pictures for example).

Dashboard Actions

Unfortunately, I am unaware of how to upload my example dashboard. However, the end result should be a blank dashboard where each sheet shows and hides itself based on the users selection in the top right corner. Dashboard final result

本文标签: tableau apiHow to change the datasourceStack Overflow