Adding average lines to Tableau bar chart - tableau-api

I have a Tableau bar chart which plots a number of measures for one particular row at a time in my data set (using a Quick Filter).
I was wondering if there was an easy way to add a reference line for each measure's average value across the entire data set.

You may have to bring in more data and use an alternative filtering method to 'quick filter' (like using a conditional expression in a calculated field). Such as:
if (condition of quickfilter) then
data
else
null
end
this way you can view only limited rows of data in your viz, while also bringing in the rest of the data for the average calculation.

Related

Displaying change in moving average on map

I am trying to show the change in moving average by county on a map.
Currently, I have the calculated field for this:
IF ISNULL(LOOKUP(SUM([Covid Count]),-14)) THEN NULL ELSE
WINDOW_AVG(SUM([Covid Count]), -7, 0)-WINDOW_AVG(SUM([Covid Count]), -14, -7)
END
This works in creating a line graph where I filter the dates to only include 15 consecutive dates. This results in one point with the correct change in average.
I would like this to number to be plotted on a map but it says there are just null values.
The formula is only one part of defining a table calculation (a class of calculations performed client side tableau taking the aggregate query results returned from the data source)
Equally critical are the dimensions in play on the view to determine the level of detail of the query, and the instructions you provide to tell Tableau how to slice up or layout the query results before applying the table calc formula. This critical step is known as setting the “partitioning and addressing” for the table calc, sometimes also as setting the “compute using”. Read about it in the online help for table calcs. You can experiment with using the Edit Table Calc dialog by clicking on the corresponding pill.
In short, you probably have to a dimension, such as your Date field to some shelf - likely the detail shelf, and the set the partitioning and addressing, probably to partition by county and address by state.
If you have more than a couple of weeks of data, then you’ll get multiple marks per county. You may need to decide how to handle that on your map.

Show number of elements in multiple sets in a chart

I create about 10 sets using my tableau data. I want to show the number of elements in all sets in a chart, for example, bubble chart, or bar chart. When I move a single set to the sheet and select the number of records and filter the in elements I can see the number of elements in the set, however, I want to simultaneously see the number of records in multiple sets.
When I try to put multiple sets to a for example bubble chart, Tableau creates one single bubble instead of multiple bubbles.
Sets are very useful, but may not be the best approach when you have a very large number of similar groupings to compare side by side when you are using them as dimensions.
Remember the purpose of dimensions is to partition your data into non overlapping blocks prior to aggregating measures. Since a data row may belong to multiple sets, using sets as dimensions doesn't fit the particular application you describe. (but using sets as filters or building blocks for calculations might)
So here is one approach that will give you some flexibility. Define a calculated field for each set to return 1 if the record is in set 1, null otherwise (One way to think of sets is as a boolean function)
Number of Set 1 Records
if [Set_1] then 1 end
Then you you can use SUM([Number of Set 1 Records]) as a measure as desired. You can use Measure Values to display multiple measures together.
This way your set definitions are used for calculating your measures, but not for partitioning the data rows.
If your sets are completely defined by a condition, and this is the only way you use them, you could simplify by using the condition directly in the calculated fields above and not creating the corresponding sets.

Tableau create one dimension by appending multiple dimensions

I have created 9 calculated fields that return the desired results. Now I want to create a single dimension (or measure if more appropriate) that combines the fields into one by appending the data, not creating a combined string field. I know I can do this in Excel very easily, but am at a loss in Tableau. Please see screen shots for more information.
Pic 1- This is the code for each calculated field (only the number of minutes are changed). > 75 also has an if statement attached.
Pic 2 - This is a combined field of all the data I want in one column. This is validating that my calculation fields are returning the desired result.
The end goal is to create a single bar chart based on the combined data. Thanks for any assistance.
I may be wrong, but get the feeling what you want to achieve can be done by dragging the "Measure Values" into your visualization, and then the "Measure Names" into color, or whatever else. You can filter on "Measure Names" to include only those measures you created, and they will be represented as one pill, but will include all of the values and retain them as individual measures.

Tableau: How to divide two table calculations?

I have these calculated measures which I use within a tool tip as table calculations
[alert_count_by_action] = total([distinct_alerts]) compute using day
[alert_count_all] = total(distinct alerts]) compute using table across
When I mouse over an action name colored widget type I can see that the [alert_count_by_action] and [alert_count_all] are producing the correct values. What I would like to do is to compute a percent by dividing [alert_count_by_action] / [alert_count_all] which I will call [alerts_by_action_percent_overall]. This is not working at all despite trying every combination available on the table calculation options within the Marks card.
What am I doing wrong?
Without the attached workbook, I can only suggest to check the partitioning of your % calculation. Because both components of the fraction are themselves table calculations, they can be partitioned separately (i.e. "compute using" options).
There should be a combo-box in the 'Edit table calculation' dialog that selects which component is being configured.
Maybe you have configured one part, but not other?

Require minimum number of data points before plotting a point in Tableau

Can I cause Tableau to require a certain number of underlying data points before plotting a point on the graph?
For example, here's a graph showing average moods over the course of the day on Tuesdays:
There's nothing uniquely awful about midnight on Tuesdays, it's just that there's only one data point for that particular time, and it's an outlier. Is it possible to have the graph show midnight as missing unless there are more than (for example) three different records from midnight being averaged together?
You could define an aggregate calculated field, called say avg_mood as:
if count(Mood) >= 3 then avg(Mood) end
Since the aggregation is hard coded into the calculation, Tableau will display AGG(avg_mood) for the field on any shelves you use it on, rather than letting you toggle the aggregation outside the formula as it will for other measures.
Note, there is no else branch, so the calculation will evaluate to null if there are less than three non-null Moods in a partition of data rows (based on the dimensions)
You can control how null values are displayed in a line chart. On the format pane, select the field in question from the pull down menu by the word Fields at the top right of the format pane, then select the Pane tab, then at the bottom of the format pane, adjust the Mark settings in the Special value section.