How to make a dynamic tableau x-axis that gets changed when a different dimension is selected as a filter? - data-visualization

I am trying to create a report for my stakeholders where we want to check the distribution by values of column1, column2 and likewise. While I could make different tabs for each column, I apparently have 55 columns (all numeric and I will be making bins for them) that the user want to toggle between for comparison on distributions - and coming up with an insight like column 43 is more skewed than column19.
Pet example:
1. Suppose I have data in below format:
2. And I want to create a tableau filter enabling the user to toggle between continents and countries, and get their individual distributions in the same view. I want to keep the measure consistent (population in this example). Something like below:
3. and generating distribution by continent when continent is selected and by country when country is selected
I know if I had wanted to toggle between different measures for the same dimension, then I needed to create parameters, but this is opposite to it (same measure but different dimensions) and I am not able to figure out.
Any comment/help will be much appreciated.

I'm afraid you'd still need to use parameters. There is no equivalent of Measure Names for dimensions so you'll have to create a parameter (I called it Dimension Switch) with Continent, Country, etc. as options and a calculated field that will look something like this:
CASE Dimension Switch
WHEN "Continent" THEN [Continent]
WHEN "Country" THEN [Country]
END
This calculated field will take on the values of whichever column you have selected in the Dimension Switch parameter.

Related

Dynamic measure that responds to dynamic dimension

I'll try to describe this scenario without introducing too much irrelevant info, but keeping it simple.
Using the newish Field Parameter feature in PowerBI, I created a Parameter called _Dimensions and another one called _Measures, selecting common columns in the former and common measures in the latter.
I then build a bar chart with [_Dimension Fields] for X-Axis, [_Measure Fields] for Y-axis, and a single-select slicer for each. Now when user selects a measure and a column, it draws a bar chart of their selected measure, sliced by their selected dimension.
What I'd like to do is actually make this a Pareto chart, which would entail putting in a second measure on Y-axis, but rather than having a pareto counterpart to every possible measure a user may select, I'd like to create a single measure that calculates running percent of total of [selected measure] along [selected dimension].
I was hopeful I could call the [_Dimension Fields] column that PowerBI created with its special properties from DAX, but that doesn't seem to treat them any different than any other column. I also tried NAMEOF, but that just returns a string. I was hoping it would act like INDIRECT does in Excel, treating the string as a reference, but alas.
Does the above problem statement make sense? Can anyone describe an elegant design approach to do this dynamically that does not involve just writing a version of every possible measure a user could select and then use a switch?
imagining the combo chart to look like this (pareto measure in line chart part)
edit: secondary question, but equally important to the end goal of a fully functional dynamic pareto: when user selects measure, I want the selected dimension to always be sorted desc by selected measure. This is how you do a pareto analysis, but PBI does not default to sort descending always, and each time you change the dimension (via slicer click) the chart resets sorting. Any way to ensure that the sort order is fixed correctly?
Calculation groups are the way to go and Tabular Editor is used to create these.
After much exploration, here is my solution. It's not 100% dynamic in that it requires writing custom DAX for each dimension and measure that you need to be available for dynamic use, but gets the job done for the scope of the report in question.
create field parameter from columns that I will want to dynamically use in viz: name it _Dimension
In my example, I will be using two columns from two tables: Carrier[CarrierNumber] and ShipmentLane[LaneCity]
create field parameter from measures that I will want to dynamically use in viz: name it _Measure
in my example, I have two measures I will want to be able to toggle between: Events_Late and Events_Late2. Both exist on OnTimePerformanceDetail table.
create measure to dynamically return value based on the selection of
_Measure in slicer on canvas. This seems like it should not be unnecessary with field parameter feature, but it is necessary for reasons that will be
clear if you try to do this without a custom measure.
create a pareto measure for each of the dimensions that may be
dynamically passed to viz. Each of these dynamically evaluates the base measure, but is specific to a single column for which the measure evaluates over:
create a dynamic pareto measure that chooses the correct pareto calculation based on the selection on _Dimension
create single select Slicers for _Dimension and _Measure
create combo chart, using _Dimension for X-axis, _Measure for Y-axis, and DynamicPareto for line Y-Axis. I have aliased DynamicPareto on the viz to Running% so that it shows nicely and clearly on legend
set the sort order of the chart to be ASC by Dynamic Pareto measure. This ensures that the dimension on X-axis is always sorted correctly
A few notes:
I named the dynamic pareto as "Discrete" because this only works as
designed when doing pareto on a discrete dimension, where the bars
are meant to be sorted desc by [measure]. If you are doing a
Percentile chart, which is basically the same thing, but the
dimension is sorted by dimension value instead of measure value, the
Pareto calculation needs to work slightly differently.
There are lots of Pareto measure patterns out there. I used the one
from this blog, because it's concise and performs well:
https://janizajcbi.com/2018/08/22/pareto-rule-abc-class-in-dax/
it is important that the slicers be set to single select
I discovered there is a Pareto 3rd party viz that is simple and
dynamic, but has very limited formatting features. Fine for quick
analysis, but if you have branding or formatting standards, it may
prove unusable, as in my case
in my production use case, I have a lot more dimensions and a lot
more measures that will be available. Started with just 2+2 to prove
out functionality. Just need to follow same pattern to add more
available dimensions and measures to mix.
my naming convention of * suffix is because this report is built on a
centralized data model. The * makes it easy to find measures that are
local to this report and not a base measure in the model I am
connected to.
the field parameter feature can only be used with a remote model like this if the preview feature of Use Direct Query for AAS and PBI datasets is enabled OR the field parameters are added to the base model. In my case, I'm adding the field parameters to the base model, and all of the measures here are local to the report, connected to remote model.

How to convert a panel bar chart to multi-line chart in tableau

I am trying to create multi-line subplots such that each subplot represents a rating factor on which firms are rated, and each line represents a firm's change in rating over time. Note that I don't have the date field. I have a string field that says which quarter of the year the Mean of ratings belong to.
I'm new to tableau and I created something like this:
I want to create multiple subplots: one subplot for each of the 8 rating features in the above diagram, and the subplot has multiple lines representing the variation over time for each company. I have 10 companies.
Please guide me on how to achieve this?
A rough sketch of how I Imagine the plot to look like is below:
This will teach you how to make a panel chart in Tableau: https://tarsolutions.co.uk/blog/build-a-dynamic-panel-chart-in-tableau/
It shouldn't to too complex for what you're attempting (fingers crossed!).
Building the panel chart is a little tricky in Tableau. Not terribly hard once you understand table calcs. I suggest starting simpler by moving Measure Names from the Rows shelf to the Pages shelf, then creating the line charts you want - 1 per page. Then learn about table calc partitions and addressing, including “At the Level” to have the info needed to define the panels
To make a colored line chart,
You need one field on columns that you set to display as continuous, making it green. If it is a date field, right click on the field and choose from the second set of groups, like month or quarter.
You need a continuous field on the Rows shelf, use Measure Values in your case
Use a discrete field on color to determine the number of lines, say Shortname
Set the Mark Type to either Automatic or line

Spotfire calculated column based on filter

I want to create a calculated column that is equal to the percent of the total of the previous column, but only for the rows that are selected.
For example, the two columns below show rows where I've filtered for only the rows of interest. The sum is accurate, but I want the percent of the total to be only out of sum of the currently selected rows rather than the absolute total (which is how it's currently being calculated). I want the percent of the total to dynamically change depending on what is filtered in the data table. Is this possible?
Image of my 2 columns:
I know spotfire somehow calculates this becuase when I insert a bar graph using % of Total(SumofComponents) the ratio is only out of the current total.
Image of my bar chart:
much like in programming, Spotfire has a rough concept of scope. and unfortunately, calculated columns are above filters in terms of scope; they have no concept of what is and is not filtered.
visualizations themselves, however, do*!
what you can do in this case is to put your expression on the Y axis (it looks like you've done this), and it will respect your selected filters*.
*caveats: there are a few ways that filtering can be negated on a given visualization:
Properties>>Appearance>>Show shadows indicating the unfiltered data. this option shows a grey bar that represents the data hidden by whatever filter selection was made
Properties>>Data>>Limit data using filterings. these options allow the viz to use separate filtering sets ("Filter Schemes" as they're called in Spotfire) or none at all (to ignore filters completely)
Properties>>Subsets. by default there are three subsets: "All Data" which ignores filters, "Not in current filtering" which inverts the filter selection (e.g., if you filter a boolean column to show only TRUE, this chart would show only FALSE), and "Current filtering" which is the default behavior. you can check the online help for additional subsets that you can add.

Qlikview: how to create summary table to filter multiple associated tables

I have 4-5 tables of single and many rows per ID. I want to generate a summary table listing each ID along with various counts and max/mins, but I want to be able to filter on calculations. Example: "ID" is the identifier and there are two tables, TestA and TestB.
One desired selection criteria: Show only those IDs where at least one TestA score >5 and there is at least one TestB score.
In a straight table, this is simple to do with expressions, but the resulting table cannot be selected on the calculated true/false value.
I think I need to create a new table in the load script containing the ID, and then various conditions labeled as I wish. Then, these fields could be dimensions. This seems similar in concept to a master calendar. Am I on the right track?
If it helps to understand my example, this a medical application; the tables are lab results and other interventions that each require complex queries pulling data from various sources that are very "hard-coded" to produce a small data set from millions of rows of highly normalized source data. The desired dimensions would be combinations of the labs so as to allow identification of patients who meet certain criteria--then, once filtered, there would be many more graphs and charts to identify what tests and procedures were followed for that group of patients.
My current data model just loads many tables which then associate on ID. I had attempted to load all data into one big table using concatenates and calculations, but this did not seem to accomplish what I needed and was difficult to manage.
IIUC, I think what you want to do can be accomplished with a combination of sliders/input boxes, variables and calculated dimensions in your table. The process is definitely burdensome, but it should allow you filter the way you want.
Add a field to your table load statement in your script like rnum as RowNo().
Create a variable for your filter(s). Ex. vFilterTestAScore.
Add a slider or input box to your dashboard and point it to that variable.
a. For slider, the option is in the General tab -> Data header -> select the Variable radio button.
b. For input box, add the correct var from the list to the list of Displayed Variables.
Set sliders/input boxes to the criteria you want: vFilterTestAScore = 5 and vFilterTestBScore = 1
Create a straight table with ID as the dimension and expressions for TestAScore and TestBScore. The expression formulas would be sum(TestAScore) and sum(TestBScore) respectively (this won't make sense until the next step).
Now add a calculated dimension to you table. The idea here is that rather than just having the ID dimension, you will create a calculated dimension that only displays the ID of the records that meet the criteria you select in the slider or enter in the input box. The formula should be something like:
if(aggr(sum(TestA), rnum) >= vFilterTestAScore, ID, null()) or for multiple filters: if((aggr(sum(TestA), rnum) >= vFilterTestAScore) and (aggr(sum(TestB), rnum) >= vFilterTestBScore), ID, null()).
On your new calculated dimension, check the 'Suppress When Value is Null' box so only results that meet your criteria are displayed in your table.
To summarize, you are using the variables to store your selection criteria which you are entering via input box or slider. Then you are conditionally displaying only the ID's in your table that match those criteria via a calculated dimension and 'Suppress When Null' option.
I can send you a .qvw if you aren't using the free personal edition and are able to open other qvw's.

How to display filtered data rows as a tooltip in Tableau Public?

Noob here, I have a table with different entries (rows) per different (repeating) regions.
I'd like to be able to display the data rows filtered - matching that particular region thanks - so I get those particular fields related to each region as a tooltip on a map. (I know how to build the map)
Thank you
Just dragging the fields you want to Details or Tooltip is not doing the trick?
Putting a measure on a shelf (other than filter shelf) includes that field in the visualization query results -- i.e. applies the chosen aggregation function to yield an aggregate result value for each partition of the data (as specified by the unique combination of dimensions)
Putting a dimension on a shelf (other than the filter shelf) also includes that field in the query results, but since the dimensions define how data rows are partitioned, it can affect the level of detail of the query. You'll notice this often as suddenly getting many more marks in your visualization after you add a dimension to a shelf. If you are familiar with SQL, dimensions define the fields that follow the GROUP BY keyword.
EDIT
Thanks for the addition, #AlexBlakemore. I've never said dragging a dimension would not work, only that it wouldn't work as the OP wanted it to (basically the same as you're saying).
And though everything you said (above) is true, it's particularly not exact when it comes to maps. Yes, dragging a dimension will further partition the data, but it will not create additional marks on a map (unless it has also geographical properties). Rather, the tooltip will get the first occurrence of that dimension, and display data for that only. For instance, if you drag "Product" to details, and the possible values are "Bread", "Coffee" and "Milk", it will probably just show "Product: Bread", and the measures for "Bread" only. So yes, it will partition, but no, it won't create additional marks.
Back to OP problem. What I believe you want is a tool tip with all values of the dimension (in my poor example you'd like to see "Bread, Coffee, Milk"). Tableau does not have functions to aggregate strings yet, so it's hard to do so.
What I would suggest is to create a separate sheet, and just drag the dimensions and measures you want to rows. Then put it side by side with the map on a dashboard, and use the map as a filter. Then, when you click on a country/region/city, you'll see the data of that region on the other chart.
Refer to: http://kb.tableausoftware.com/articles/knowledgebase/creating-filter-actions-dashboards
or https://www.tableausoftware.com/learn/tutorials/on-demand/authoring-interactivity