Display Tableau label to show group breakdown - tableau-api

I grouped my countries as followed (I used create --> group):
Asia = HK, JP, SG & Other = all other countries
So I am working with the following dimensions:
"Region" is the group created above. "Country" is the list of countries (e.g. HK, JP, SG, VT, CA, US, etc). "Date" & "Quantity"
I displayed a line chart that show trend for these 2 groups, so basically, on the same graph, one line shows the trend for "Other" and the other shows the trend for "Asia". "Day" is on the column shelf and quantity is on the row shelf, and I put Region on the color shelf to obtain the 2 lines. I also bring "Country" on the Filter shelf since I want to be able to view individual countries.
In the labels, when "ALL" is selected for "Country", I am able to display "Other" and "Asia". What I want is the label to change to the actual country when I select an individual country. For instance, if I select HK, I will only see the HK line, which is fine, but the problem is that it is labelled as "Asia" instead of HK. How can I make this happen?
I tried to add "Country" to the Label mark, unfortunately, that breaks down the trend lines to show "Other" and then all the countries that fall under Asia. I really just want to have 2 lines (or just one it a single country from "Country" is selected).
I have been banging my head trying calculated fields and parameters and can't get this to work. Please help!

This may be a bit extreme, but I can't think of another way.
With your 'Region' group on color and label, Tableau has no way of knowing when it is appropriate to change label to 'Country.' A calculated field would be very difficult to create here.
What I would propose is two completely separate sheets that are switched upon a user's input. Here is some documentation on how to create a sheet selector.
The method would generally be to:
Create a string parameter. Inside the parameter creation window there is an option "Add from Field" which would allow you to import all of your "Country" names. You will need to add an "All" label on this screen as well.
Create two views. One which is the one you already have that will show "All" and have two lines. The other new sheet will be designed for only when a single selection from the parameter list is made. It will only show one line that is labeled with the parameter (Country) name. You can design it however you'd like since its a totally separate sheet.
Follow the instructions in the link given above. In the article, on the step labeled "Type the current view's name (like “Map”) in the text box, and click the Add Item button." you will want to type the parameter name "All" in your first sheet and then in the second sheet you will want to individually label each country. The parameter drop down will trigger one sheet or the other for display.
A major consideration here is how often any fields are added to [Country]. Keep in mind that the parameter list will not automatically be adjusted if the underlying data changes.
I hope this helps.

Related

Tableau | Display different sheets by selecting option(s) from one particular filter

Is there a way to display different sheets by clicking/selecting values/options from one particular filter?
for example, if I have this filter:
and I need to display a sheet named Departments when I select Commercial from the filter shown in the PtrScn.
However, When I click/select any other options like HR, Information ...etc, I want it to display the associated sheet with the filter "Filter by Sector"
Any hints would be highly appreciated!
NOTE: I use tableau 2019.1 and it does not show "Change Parameter" that might be needed to approach this as I noticed when I have been researching for two days now!
You should use a container (say vertical) where you wanna put your N worksheets one on top of the other one without changing vertical spacing: just let Tableau do its stuff!
Be sure to remove the worksheet titles.
Once you're done, you need to create a parameter in order to handle all the N possible choices, and according to that you need to create N Calculated fields with a condition like this one:
if [Param] = 'Profit' then 'ok' else 'ko' end
Each calculated field will be used as a condition (select just ok values) in your filter selection.
Since the parameter can accept just one value a time, you will have just one of your N worksheet displaying data.
And this is the trick based on the vertical conatiner: if you hide worksheet titles, you will see "something" just for the selected worksheet and Tableau automatically will handle all the vertical space in the container.
The result will look like the following:
Adding to Fabio's great answer, these resources about collapsing containers may be useful:
Sheet swapping using collapsing containers
Automatically resize items in a Tableau container (or make disappear in your case)

How can a Tableau Server user change the axis view on a granular table?

I am creating a capacity dashboard that has a granular aspect with multiple rows on the axis. The purpose is so that the user can see the specific view as the fields get more specific, such as Region to Market to Territory. My main problem is if there is a way for a user on Tableau Server to be able to edit the axis (maybe through a filter) so they could basically scale back the granularity a little bit. I know that in Tableau Desktop, you can just remove the dimensions, but I am hoping there is away to do that as a user in Server. Here are some pictures of my
workbook for examples:
You can see that when Territory is removed, it get less specific and shows all of Canada as a whole, grouped together. I am hoping there is a filter view or some way a user could change this dynamically. I have created a parameter with strings that matches the row dimensions that maybe when selected, will show up to that row, but I am not sure how to link that into the dashboard. Here is a picture of that:
Thank you for any help!
The best way to do this is to create a Parameter with your three Axis choices. It should look like this:
Next, create a calculated field that only references the Parameter like this:
Next, you will create three separate sheets. On each one, add the Axis Filter to the Filters Shelf. One each separate page, select one of the three values in your Parameter. (Tip - if the value doesn't show up you can either change the parameter or type it in manually under "Custom value list".)
What this does is create a filter whereby only ONE of the sheets will show up at any time. Meaning if you want to work on the Market sheet select the Market value in the Parameter.
Finally, to bring it all together, you will put these on a dashboard. Create a new Dashboard and add a Horizontal (or Vertical, it doesn't matter) Object (aka layout container) onto the dashboard. Put all three Sheets inside the layout container. You will see only one will be displayed but all three will have headers. On each sheet, click on the header and check "Hide Title" like this:
Finally, click on any downward triangle and show the parameter:
Now, by changing the parameter your user is selecting from three different sheets... effectively letting them change the Axis.
You can also view this documentation on the Tableau Help site.

Create Actions From Tableau Map (with points)

I am familiar with how to create actions in Tableau, but doing so with map points has stumped me. It seems as though Tableau uses the lat/long measures uniquely and different than how it would another measure.
The expected behavior I want is a user to be able to select a single map point from a Tableau sheet so I can use that selection to drive an action (in this case adding the selection to a separate, blank sheet).
Here is one workaround, but this isn't a stable solution for the end-user:
1) Find desired map point -> right-click -> keep only
2) From the new 'Inclusion' pill that appears under 'Filters'...right-click -> apply to worksheets -> selected worksheets -> choose sheet
Thanks, Vamsi. I solved this morning a bit differently, it was actually really easy and didn't require any calculations:
Used carrot on my map's toolbar to 'Use as filter.'
Added a hidden crosstab to the same dashboard that, of course, changed to show the chosen map point.
Used that sheet to power my other calculation.
Essentially, I had to have both sheets on the same dashboard which allowed 'Use as filter' to solve my challenge.
(A) As each map point (generated lat/long value) is linked to a specific set of Geographic dimensions, you can create an index/combination of these fields as a calculated field.
For example, if the fields "City", "State" are the geographic dimensions, create a calculated field
Index = [City] + ", " + [State]
After you create an Action filter from the map to the desired blank sheet, at the bottom of the "Add filter Action" window use "Selected fields" under Target filters and click Add filter. In the pop-up, select the recently created Index field for filtering.
(B) You can also just add the City and State fields separately into the "Selected fields" in the Action filter and not have to create the Index altogether.
In both ways, even if there are multiple rows of data for the same location on the map, the result would show all those rows.

Showing comparison across groups in tooltip Tableau

I have a dashboard that lets users compare a company selected from a drop down menu (Company A) to another company chosen from another drop down menu (Company B). This then displays stacked bar charts (5 categories) by year. I want to build a tooltip so that when the user hovers over one of the 5 categories in either set of bar charts, it shows a comparison of that category between Company A and Company B. Is this possible, and if so, what is the best way to do this?
My previous answer showed a different approach for the problem without using too many workarounds. This answer will try to give exactly what has been asked.
First thing to understand is that you can't have the values for two different companies if you're filtering to show only one company. That means you'll need to circumvent this by filtering directly on the field.
Step 1: Create the new parameters that will be used as filters.
You want to create two parameters called "Company 1" and "Company 2" that will be used in each view to filter the company on the graphic.
Step 2: Create the new measures with the filter directly in the field.
Now you should create two new measures from your main measure, each one filtering one of the companies accordingly to the parameter, e.g. Sales Company 1 and Sales Company 2.
Step 3: Create a field with the variation and add it at the tooltip mark.
Simply enough, you want a calculated field with the difference between them:
SUM([Sales C1]) - SUM([Sales C2])
Step 4: Update the views and dashboard
Change the measure in each of the views for their following specific measure field, and remove the Company filter. And in the dashboard, substitute your usual filters to the parameter (which will be used to filter both views).
By assuming you have a dashboard with two views, you'll be filtering the [Company] in both of these views, making the value of another company not available to be shown at the tooltip.
If you're not using it yet, you could try a new approach and see the variance between companies by using the Color mark. By adding the [Company] as color, you could turn the Stack Marks off and add the second company in the filter to be able to visualize the difference.

Compare one subgroup vs all others in user-friendly way

I want workbook readers to be able to select different values of a variable to change a chart comparing that subgroup vs. all others grouped together.
For instance, using the Superstore sample data, I can create this chart comparing the percentage of sales by category, by region:
I want the user to be able to specify a region and see a comparison of that region's sales distribution vs. all other regions combined. For instance, I can create a calculated field to group into Central. vs all others, using:
IIF([Region] = "Central", "Central", "Others"), which I can use to make this chart:
But I want the user to be able to specify the region to compare (Central, East, South, West) to others. This approach hard-codes the comparison. How can I make this something the user can click around on to explore?
I would first create a parameter, specifying "Allowable values" = "List" and then using "Add from Field" and selecting Region, like this:
Right-click on the parameter (I called it RegionCompare) and select Show Parameter Control. The user will then be able to click around.
Then create a calculated field called Selected_Region defined as:
IIF([Region] = [RegionCompare], [RegionCompare], "Others")
Then place Selected_Region on the Rows shelf and you'll be all set.