Foundry-workshop : add average value on a chart displaying parameter evolution - charts

I'm looking for a way to display a line showing the average value of a parameter in a chart dedicated to this parameter's evolution.
I have a dataset, let's take as an example the following structure :
Product | Month | Price
P1 2021-01 13.00
P1 2021-02 13.50
P1 2021-03 15.00
P1 2021-04 14.50
P2 2021-01 3.00
P2 2021-02 3.50
P2 2021-03 5.00
P2 2021-04 4.50
In a chart, I display de price's evolution for each selected product (multi select filter upstream) and I would like to add, also for each product, a line showing the average for the displayed period.
I tried so far 2 different approaches:
Use multiple series and add one dedicated to this average. But I did not manage to calculate this average. Actually, to display the initial chart, the evolution of my property, it looks like I must use an aggregation function (each layer type requires to define series where the first parameter to define is an aggregation function)
Create a summary dataset, with aggregates values for each product, and the latest calculation date. It looks like this:
Product | Latest Month | Avg Price | Max Price | Min Price
P1 2021-04 14.00 15.00 13.00
P2 2021-04 4.0 5.00 3.00
But I'm not able to overlay these values, as there is no time series to define the same X-axis.
I considered a 3rd solution, but looks dirty to me: to add the aggregate values in the first dataset. Each row would contain avg/max/min values for the period of time so that I can display these values the same way as any other property.
Finally, writing this post made me wonder if I well understood how this tool works, as I feel that what I implemented should have led to display the average values I'm looking for, but it's the only way I found to display a "simple" property's evolution.
Thanks in advance for your help.

There are a few considerations at play here with regards to building your charts that lead to different approaches when it comes to deciding how to represent your data.
One point up front about charting in Workshop is, as you've observed, the chart expects you to aggregate the granular per-object data to create each data point of your visualization. If you want to instead draw some feature of the chart (a dot or bar) per object, then you'll need to select an appropriately narrow bucket size. In this case, if you have one object per product per month, then choosing a granularity of monthly or less should result in having one data point per object.
As for options related to deriving the average, let's look at three approaches:
Temporal Metrics Schema
Creating an ontology with a primary object (i.e. the "Product") and then a linked object type for storing values of metrics about that object (i.e. the "Product Metrics") can be a flexible approach that works well with Workshop and Quiver charting expectations.
Consider a modification of your original granular schema like this:
Product | Timestamp | Value | Metric Type
P1 2021-01 13.00 Monthly Price
P1 2021-02 13.50 Monthly Price
P1 2021-03 15.00 Monthly Price
P1 2021-04 14.50 Monthly Price
P2 2021-01 3.00 Monthly Price
P2 2021-02 3.50 Monthly Price
P2 2021-03 5.00 Monthly Price
P2 2021-04 4.50 Monthly Price
P1 2021-03 14.00 Quarterly Average
P2 2021-03 4.00 Quarterly Average
...
This schema is quite flexible and robust; you can easily add new metrics later, or even use a tool like Taurus to let users define their own rules to generate metrics that fit into this schema. It has the advantage of storing the metric type as data itself, which means that in your Workshop app, for example, you can let the user choose, using a Filter List widget, which metrics to display on a chart.
This pattern also ensures consistency of what the date "means" when presented to the user. Having, for example, a quarterly average pre-calculated means that every user will get the same information from reviewing the chart, regardless of what time period they filter to, whereas a dynamic average based on the user's selection could lead two different users to quite different conclusions based on how they chose to filter the data.
And finally, for this pattern, it becomes quite easy to show the chart itself, since you simply choose to plot the filtered object set of metrics and choose the "Metric Type" as the series property, bucket by a small granularity (say "Day") and have the chart interpolate any gaps. This means that even aperiodic metrics along with metrics recorded at different periods can all render on the same chart.
This pattern is somewhat formalized with the nascent Time-Dependent Property feature of the Foundry Ontology. If the Time-Dependent Property feature is available on your Foundry instance, you can read more about it in the Ontology product documentation in the "How to create a Time-Dependent Property" section.
Dynamic Charts with Functions
Let's say you don't want to precompute the metrics for whatever reason, and instead want your chart to exactly render a line based on the average price values that are in the object set. One approach to accomplish this is to use a Function-backed Chart and a simple Typescript function that takes in as a parameter to object set of price information and returns a 2DimensionAggregation type that represents two data points: the first and last timestamp of the period represented by the input object set each paired with the average value calculated across the price values or a 3DimensionalAggregation since you perhaps want these two data points for each product category.
You can find clear steps in the Workshop and Functions product documentation for producing Function-backed Charts as well as examples of various Typescript Function implementations in the Foundry Training and Resources project on your Foundry instance.
Dynamic Charts using Quiver
The Workshop XY Chart is still under active development and a number of features that might be useful are not yet available. In some circumstances creating the chart in Quiver and embedding it in your Workshop app with the Quiver Canvas widget can give you flexibility to build charts with "derived" values that you cannot currently accomplish directly with the Workshop chart.
I'm adding this for completeness; I don't actually think it'd be the best solution in this specific case. The power in this pattern comes from taking an object-backed bar or line chart in Quiver and using the "Convert to Timeseries" feature to unlock Quiver's timeseries plotting and transformation capabilities. You can check out the Quiver documentation for more guidance on how to create object-derived timeseries and how to turn a Quiver canvas into an Object Template to be embedded elsewhere.

As far as I understand, according to #Logan's answer, the documentation, my tests, the solution is based on a key feature I did not really understood before: a chart always displays an aggregate value of a property.
It's something I noticed and mentioned in my question, and I just understood how this aggregation is performed: there is no parameter to define an interval of any kind, but when your X-axis is a date, you need to select a bucket, and that actually is the aggregation interval. If your date is daily basis and you decide to display values at weekly level, the aggregation is based on 7 days.
Thus, the solution I found was just to add exactly the same layer than my monthly values, I just changed the bucket in the second one to display yearly values (it was actually what I was looking for, my sample data were just one quarter because I did not see it would have had an impact).
But if I needed to visualize a quarterly average (#Logan's answer made me asked), how should I proceed?
I assume I would have several approaches: the ones described by #Logan, even if I'm still doubtful about the first one. At least, I looks like function-backed chart would work, but I do not know typescript at all to implement such functions. Otherwise, preparing data in the same dataset, or in an another one, designed to be displayed with the same scale, might work as well.
How to deal with a rolling average?
Well, I'm not sure it's possible, the only solution I see is function-backed chart but, one more time, I do not know typescript... I would probably use Slate instead, where I'm sure I'll be able to implement it.
Of course, any comment is welcome here, as I am still in a discovering phase of this tool.

Related

How do I plot one measure per axis in Tableau?

I have a problem that I have reduced to its essence with the following CSV file. Imagine we're a company that sells potatos and apples, and each customer is assigned a potato-class and an apple-class.
What I want is to plot the sales according to class - so apple sales by apple class and potato sales by potato class, in one diagram. Dragging all the measures into a workheet, I get this:
So I would like an overlay of the top left and bottom right classes.
If I combine everything into one diagram via dual axis, I get this:
So Tableau is plotting potato sales and apple sales on both the potato and the apple class axis, creating four dots per class where I want two.
Does anyone have an idea on how to basically assign one measure to one axis instead of both measures to both axes? (Hiding the "wrong" dots would also be fine).
Also, I realize that pivoting the dataset to have fields "sales", "class" and "product" would solve the problem, but reality is of course far more complicated than this toy example and it's just not feasible.
Thanks!
You'll likely have an easier time if you reshape your data first, say to have the following columns "Customer,Item,Class,Amount" -- so each row in your original data set would yield 2 rows in the transformed version of your data set. Tableau Prep can make those types of transformations easy (and repeatable), but it is possible to do something similar in Tableau Desktop alone (using a self-union and some calculated fields).
So the first 2 lines might be:
Customer,Item,Class,Amount
1,"Apple",1,2
1,"Potato",1,4
Either way make sure Class is treated as a dimension in Tableau.
Data wranglers often call this a tall format instead of a wide format.

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.)

Showing values for overall dataset as well as subset

I have a dataset that contains various wait-time metrics for all appointments in a practice for a year (check-in to call-back, call-back to check-out, etc). It contains appt time (one of about 40 15 minute slots), provider, various wait times.
I can get Tableau to show me, for each 15 minute slot, the average wait times for each provider in the practice.
What I can't seem to be able to do is also display the overall average for the practice for that given time slot so as to be able to compare that provider vs. the "office standard".
I'm super new to trying out Tableau, so I am sure it is something very simple.
Thanks in advance.
Use a level-of-detail (LOD) calculated field. An LOD calculation occurs at whatever aggregation level you specify, rather than what's on the row or column shelf.
You didn't provide any info about your data set so I will use made up names here.
This gives you the overall average wait time, regardless of other dimensions on row/column shelves:
{FIXED : avg([wait time])}
This gives you the overall average wait time per provider, regardless of other dimensions on row/column shelves:
{FIXED [Provider Name] : avg([wait time])}
See the online Tableau help at https://onlinehelp.tableau.com/current/pro/desktop/en-us/calculations_calculatedfields_lod_overview.html for more information. If you have filtering and need to calculate the overall without filters applied, look at the INCLUDE LOD keyword.

splunk - create chart with values function

Background: Soon after my performance test, the response time details of the business transactions will be fed into splunk, from where I need to generate trend graph for couple of transactions for certain period of time.
Now I am able to group the response time data for these transactions but in visualization, not able to generate the chart.
Refer:SS01.jpg for more details.
query used: index=xyz source=abc (Period!=Period) Transaction_Name=Search OR Address_Book OR Policy | chart values(Average) as Average by Transaction_Name
I want the chart to appear in either format A or B as it appears on SS02.jpg.
Please help me on this.
Thanks.
You have very low values (i.e. 0.046, 0.099, etc) in the query output and very high value in the chart Y axis (100), in order to get the desired picture just reduce the maximum value for the vertical axis like:
To make the changes permanent you can amend charting.secondaryAxis.maximumNumber parameter value like it described in Controlling chart (y axis) range
Personally I prefer BM.Sense output for performance test results analysis.

Table Structure for Tableau

I have a query regarding the table structure for the pie chart on Tableau.
I have below 2 table structures and am not sure which one is more apt for tableau to arrive at a pie chart .
For example I wish to see the percentage of each metric over a particular date contributing towards the total. May be the representation is a pie chart or some other chart. Please suggest me which table lay out works out well for my requirement.
Note : I have done all my calculations to arrive at the total in my database table itself.
Could some one please help me out.Thanks!
Table 1 :
Table2 :
Pie charts first take a series of data and sum the total. Then they calculate the percent of each element of the series and create a pie slice with a unique color. To make a pie chart, you need one measure (the category or label) and one dimension (the amount of that category).
If you need to see how one is made, I would suggest downloading an example workbook and then going to the pie chart sheet. One example is here.
Here is how it looks when set up in Tableau.
Personal note: Despite the name, pie charts are not that delicious. Here is advice from Tableau themselves. And here is something I made up to express my feelings.
Relating to the topic of pie charts, and how to best represent data where contributions to a whole are of interest, I would recommend bullet graphs as well. Here are two papers by Stephen Few that could be of interest:
Save the Pies for Dessert
http://www.perceptualedge.com/articles/08-21-07.pdf
Bullet Graph Design Specification
http://www.perceptualedge.com/articles/misc/Bullet_Graph_Design_Spec.pdf
And, to answer your question on data preparation for Tableau, it looks like the second table would be more appropriate. Here's a good KB for preparing data for analysis, note the last section on the Tableau Reshaper tool for Excel...can save a ton of time.
Preparing Excel Files for Analysis
http://kb.tableausoftware.com/articles/knowledgebase/preparing-excel-files-analysis