Displaying change in moving average on map - tableau-api

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.

Related

Form data evaluation

I have a form data wherein tableau I am using the below value to find out the choices for a multiple value question. The question is Could you please indicate one or two areas where we fell short.
the value can be explosives, vehicles, cement etc
I have individually accounted for each of the choices in the below calculated field:
int(contains(lower([Could you please indicate one / two of the following areas where we fell short of meeting your expectations?]),'factory'))
Similarly I have found out for other values:
The calculated fields are hasvehicle, hasfactory etc
But the problem is how can I visualize the same in the form of bars?
All I am able to do is this:
How can I visualise the same in the form of bars side by side?
When you have one measure on Rows, drag the second measure and drop it in the axis.
It will result with Measure Names on the Columns shelf and Measure Values on the rows shelf.

Custom x-axis values in Power BI

I want to plot a graph over a year+weeknumber on the x axis.
Each data-point contains this specific value; for example week 7 of 2016 is expressed as 201607 etc. and called YearWeek
I created a date table in which I calculate all possible YearWeek value in a certain date-range. Then I created a YearWeek table extracting all distinct YearWeeks.
This I connected to the Fact-Table. What I want to chart is exactly according to this matrix:
Note that I explicitly selected to show items with no data to obtain the full time line. It continues down to 201852 but you get the picture.
When I attempt to plot this, it results in this:
It's hopefully clear that the straight lines running from 201652 to 201700 and 201752 to 201800 are the problem.
There's three things to note:
I explicitly need to keep the x-axis continuous, no gaps in the plots or x-axis values skipping several weeks for lack of data.
PowerBI somehow does not want to accept that these values count to 52 and then continue in the next year and decides to make the values strictly numerical despite these values not existing in the YearWeek dimension table.
If I change the values to text, PowerBI recognises that these are distinct categories, but it won't provide a continuous axis, just the values for which there is data.
I've tried to connect the YearWeek Dim table to an actual Date Dim table hoping that time intelligence would kick in; the problem is that both for the Fact Table and the Date Dimension table the YearWeek Dim is the unique value which won't work given the filter-direction. If I start messing with many to many relationships or bi-directional filtering I'm out of my depth.
How to fix this?

Tableau average line on chart of averages

I have a bar plot with average values for some dimensions, let's say: weekdays. Now I want to put an average line on it - I use Analytics > Average Line. The line I get doesn't show the average for all data examples though, but the average counted from the aggregated values on the plot (avg from 7 values).
Can I get somehow the other one?
Put whatever your [Value] field is called on the Detail shelf. Then double click on it to edit it on the shelf
Change the expression to Total(Avg([Value])) where Value is the field you are displaying
Use this field for your average line, Read about Total() in the documentation. You may also need to edit the table calc addressing and partitioning characteristics to scope your total as desired (although the default settings often work) Read about Table Calcs in the on-line help for more info

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.

Adding average lines to Tableau bar chart

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.