Compare one subgroup vs all others in user-friendly way - tableau-api

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.

Related

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.

Filtering by a calculated measure involving multiple fields in Qlik Sense

I am trying to use a calculated measure as a way to filter my data, but it's looking more difficult than expected. Let me explain through an example.
I have data of the following type, with two dimensions - one is a unique ID, the other a category - and four measures.
Initial table
My first step is to rank each element by its score, where the ranking is evaluated within the same category. I therefore create a new measure:
=aggr(rank(sum(Score1)), Category, UniqueID)
I do this for all three scores, resulting in three new calculated measures. My final calculated measure is the average of the three rankings. Below the example, the calculated measure of interest is the one in bold. Note that in my real world calculation I directly evaluate 'New Measure', without creating the intermediate columns 'RankingScore'.
Data with newly calculated measure
Note that this measure is tricky, as it changes according to previous selections. Say, for instance, that I select only entries with 'Amount' > 1000. The relative rankings will change and therefore also 'New Measure'.
In my actual App I need to filter my entries by 'New Measure', after I've done some previous selections on fields like 'Amount'. If it simply were a field, I would normally have created a filter pane, our used the qsVariable extension to have a slide range, to select only rows with 'New Measure' above a set threshold. Unfortunately it seems I cannot do that with my calculated measure.
How would you approach the problem? I was wondering, for example, if it were possible to 'convert' my new measure to an actual field, after all previous selections have been done, but perhaps this is nonsense.
Thank you in advance, and apologies for the long post!
If I'm understanding correctly, I believe this solution should work:
Create a variable for your slider: new_measure_slider.
Create a New Sheet Object -> Slider/Calendar Object.
Configure your slider to control your new new_measure_slider variable.
Create a calculated dimension in your chart substituting your 'New Measure' formula (the one you stated was an average of the three ranks). It should be a conditional like this:
=if(aggr([your average formula here], Category, UniqueID) >= new_measure_slider, [Category], null()).
Basically, compare your formula to the new_measure_slider variable. If true, use the Category (or UniqueID, whichever you need) as the dimension, if false, null().
Check the 'Suppress When Value is Null' checkbox on your new dimension. This is key. This is what will actually filter your chart.
In the chart properties, Presentation tab, click on your new calculated dimension and hit 'Hide Column'. We don't need to see this because we are using it only as a filter.
You can tell QV to ignore your filtering in the field Amount by adding "Amount=" to your set analysis.
I dont know how your average calculation looks like but maybe:
(aggr(rank(sum({<Amount=>} Score1)), Category, UniqueID) +
aggr(rank(sum({<Amount=>} Score2)), Category, UniqueID) +
aggr(rank(sum({<Amount=>} Score3)), Category, UniqueID)) / 3

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.

Show calculated measure in row?

I'm using Tableau Desktop 9.0 on OSX. I have data (loaded from a local CSV file) that looks like this:
code,org,items
0212000AA,142,10
0212000AA,143,15
0313000AA,142,90
0314000AA,143,85
I want a chart that shows the number of items beginning with 0212 as a percentage of all items, for each organisation. (I mean as a percentage of the organisation's items - for example, in the above, I would like to show 0.1 (10/(10+90)) for organisation 142.)
I have been able to get part way there, by adding org to Columns, and SUM(items) to Rows. Then by adding a Wildcard filter on code, for starts with 0212.
This shows me the number of items starting with 0212, by organisation.
But what I don't know how to do is show this divided by the value of all items for the organisation.
Is this possible in Tableau, or do I need to pre-calculate it before loading my data source?
One way is to define a calculated field called matches_code_prefix as:
left(code, 4) = "0212"
You can also define a parameter called, say, code_prefix to avoid hard coding the prefix string:
left(code, 4) = code_prefix
And then show the parameter control for code_prefix to allow the user to interact with it.
If you use this new field as a dimension to separate SUM(items) according to those that match the prefix and those that don't, you can then use a quick table calculation to get the percent of total.
For example, you can place org on the Rows shelf and matches_code_prefix on the Columns shelf, and SUM(items) on the Text shelf to make a table. Then under the analysis menu, turn on grand totals for both rows and columns to see the behavior. Next, right click on SUM(items) and choose Quick Table Calc->Percent of Total. Tableau will display the percents of total in the table.
If you want the percent of total defined differently than the default, then right click on the measure again and set Compute Using to a different value such as matches_code_prefix in your case. It's usually better to set compute using to a specific field.
If you only want to display the value for the matching case, select the column header you don't want to see and choose hide. You can also turn off the grand totals from the analysis menu when you are done.
When you are confident in the values in your table, you can turn it into a bar chart for example by moving matches_code_prefix to the detail shelf and the measure to the Columns shelf.
--
The above is the drag and drop approach. If you prefer to hard code everything in a single calculated field that is calculated on the database side, you could instead define a calculation such as:
zn(sum(if matches_code_prefix then items end)) / sum(items)
Then set the default number format for that field to display as a percentage