Blueleaf
Blueleaf

Reputation: 49

How do I create a field or parameter that can help me toggle between two measures?

I have 1 excel file with 2 sheets (Imports and Exports) and each sheet has a table.

Each table looks like this:

Country Name    Year    Thousand of units
Belgium         2005    1,044,074
Belgium         2006    1,092,214
Belgium         2007    1,079,477
Bulgaria        2005    25,660
Bulgaria        2006    34,310
Bulgaria        2007    60,228
Czech Republic  2005    261,999
Czech Republic  2006    262,207
Czech Republic  2007    254,053

As a visualization option, I'm using the world map view and can use AVG([Thousand of units]) for each Import and Export option (drag and drop in Marks card), but I would like to use a toggle between AVG([Thousand of units (Imports)]) and AVG([Thousand of units (Exports)]) - like a parameter option.

Please note that I'm currently using Tableau 10.2

Upvotes: 1

Views: 46

Answers (2)

Blueleaf
Blueleaf

Reputation: 49

I managed to find a solution for this:

Create a Calculated Field:

Case [Select Imports or Exports] WHEN "Imports" THEN [Thousand of units (Imports)] WHEN "Exports" THEN [Thousand of units] END

Create a Parameter:

Data type: String

Values: List

Value Imports - Display As Imports

Value Exports - Display as Exports

Add both to the view!

Upvotes: 0

Alex Blakemore
Alex Blakemore

Reputation: 11896

When you edit the data source in Tableau, drag one sheet on top of the other in the central pane of the data source editor (where is says Drag Sheets Here) to make a Union of both sheets.

Then rename either the Sheet or Table Name fields to be Type or such to distinguish imports from exports.

Upvotes: 1

Related Questions