Tableau Percent Difference Between Week - tableau-api

I am trying to display a graph that shows the increase or decrease in percentage of calls from each country over time (sample data and desired output below). This is intended to answer the question, "Has the proportion of calls within the USA compared to the others gone up or down in the past week?", not to be confused with answering the question if USA has just seen more calls.
In the example below, I am looking for a bar chart that shows increases/decreases for all of the countries (x-axis = country, y-axis = percent difference)
I understand how to do this based on a simple change in count, but am struggling to look at this as percent of the total.

Sounds like you want to do a Table Calc on a table calc. No problems to do this. I suggest creating the first calculated field and saving it as a new calculation. Then use that field within your final table calculation.
If you're creating the table calculation using the Quick Table Calculation, double click in the pill to see the underlying formula - you can copy this out and paste into a new calculated field.
You are also able to set the "Compute Using" separately using this method, which may be useful in this example.

Related

Tableau Subcategory percentage calculation

I have a dataset on demography of the people and their claim amount. In the attached image, i am trying to calculate percentage difference between old and new claim for a particular car type (here, minivan) and two different 'car use' type. You can see the formula i have used to calculate in the screen shot but this formula is not giving correct answer (seems like its calculating for whole dataset).
How should i write the formula to get percentage difference between old and new claims for particular car type and car use? Tableau Screen Shot
You haven't opened the expression editor, so we're unable to see the calculation you are using here, though looking at your layout, the expression you need is:
(Avg(Clm Amt) - Avg(Oldclaim)) / Avg(Oldclaim)
Steve

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.

How do I sort this scatter plot?

I would like to sort this scatter plot, which is summarized with a Band that includes Minimum, Average, and Maximum.
I would like to sort it in 2 ways:
by Average
by Widest Range (ie difference between Minimum and Maximum values)
Tableau Public workbook
If you can't view this or I'm not allowed to post external resources on stackoverflow, then perhaps you can show me on this screenshot what I would click to get started on the following sort
Also, bonus question, is there a way to create a control for the user to toggle between the 2 sort methods in the same chart? Or do I have to duplicate the chart with a different sort type for each?
One note is that I only have Tableau Public version since I'm evaluating the product. Until I get a paid version, I can't open a workbook file unless you publish it to Tableau Public cloud. But rather than give me the workbook answer, I would just appreciate it if you gave me instructions to do this as this is more of a learning exercise.
Thanks!
Somewhat unfortunately, you'll have to replicate the min,avg,max by creating 3 calculated fields. Tableau cannot operate on the values placed on the view via reference lines.
These calculations might look something like these:
{Fixed [Cwe]: Min([Cvss Score])}
~
{Fixed [Cwe]: Avg([Cvss Score])}
~
{Fixed [Cwe]: Max([Cvss Score])}
In general, from there, you should pretty easily be able to apply them to the view and sort. Average will be easy. The difference between Min and Max will just need a subtracting calculated field to sort by. Once they're on the view, I'd put them as a dimension (column) to verify that the numbers look correct.
Take note that LOD calculations take place before filtering, so you'll want to put the Cvss filter you have there 'on context' by right clicking it and clicking 'add to context'
Here is how I would complete the sorts:
Starting with all the above calculations on 'Rows' and ensuring that they are 'Dimensions' (Blue).
After right clicking "Sort..." on [Sub-Category] on 'Rows'. Select which field to sort by.
From there, the calculated fields can be taken off the rows column. (They were only there in the first place to ensure that you could check that the sorts took place. They don't actually need to have been there in the first place.)

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?

Generating values in cells based on other cells in Tableau

I work with passenger counting in a rail-company, and I have a question.
We only have automatic passenger counting system in on train, and that train doesnt go every hour of the day.
Here you see a table of when I have data, and when I dont have data:
I want to generate/calculate numbers in the white fields, based on the other fields, so we can have more correct total numbers of passengers.
Is this possible?
You can try to Pad data using IFNULL inbuilt Function.
IFNULL(SUM([NUMBER_OF_PASSENGER]),WINDOW_AVG(SUM([NUMBER_OF_PASSENGER])))
Instead of WINDOW_AVG you might select any other Analytics you want like WINDOW_SUM , WINDOW_MAX etc, whatever fits best .
Remember this is table calculation so your original measure must be there in the Sheet, you can hide it later in the viz .
Let me know if this works for you.