Tableau map tooltip not displaying average reference line - tooltip

I created a chart visualising the cost of living in different cities and entered a line indicating the average. When integrating this sheet into the tooltip of my map, the line is not representing the average anymore but the actual cost of living for each city. I have been trying a lot but can't seem to figure it out. Thankful for any tip!

That's because the tooltip, triggered by the click/hover, is taking into consideration just a city at once, and so the average value is equal to the sum of that specific city: you're running average on just one city.
In order to compute the correct reference value you should create a calculated field like this using LOD:
{ FIXED : SUM([Cost Of Living])} / { FIXED : COUNTD([City])}
Then you could use that calculated field in a dual axis chart.
Doing so, since EXCLUDE acts before dimension filters, you will be able to preserve your average across City even though tooltip will trigger a filter.
Take a look at this simple example made with superstore and keep and eye on the red line (LOD v2) which relates to the calulated field above.
As you can see there's also a blue line which relates to the previous calculated field I wrote (LOD v1):
{ EXCLUDE [State] : AVG( { FIXED [State] : SUM([Sales])})}
Once we move to our main worksheet triggering the viz in tooltip, you'll see that the red value still keep the correct value calculated on all data, while the blue value is taking into consideration just data according to filter.
In fact FIXED is the only LOD calculus which act before the dimension filters and it's able to bypass the filtering triggered by the tooltip.

Related

Google charts how to display friendly time duration labels?

I am trying to build a graph highlighting response times percentiles
On the X axis I have the percentiles from 1 to 100
On the Y axis, I have the the response time in seconds (I used a log scale).
To make the graph readable, I'd like to show friendly labels for values of the Y axis (or the datapoint themselves). It also makes sense to use the log of the duration so I can easily show days, weeks or months on the same graph. I found out it's possible to add labels to a series.
The problem, is that I have too many values, so if I show the friendly label on each datapoint, it's too hard to see anything
Here is how it looks like
When I see this, I say to myself, that it would make sense to only show the data label for one out of X datapoints (in this graph, maybe one out of 4 would look rather neat). Is there some way to easily do this ? Or maybe there's some other approach that could be used to have a nice graph representaiton of durations ?
Also, is there a way to "translate" the values of the Y axis instead of adding the labels on the datapoints ? (the number of seconds does not make sense but the number of days or months does, I'm using a Ruby helper to generate those values, but if something similar exists in Google I'd gladly take it)
EDIT : the source sheet if you'd like to experiment
The solution could be to create an additional column specifically for annotations and specify it as a label for the series. I did the following:
Add a new column Annotation
Fill it with a formula =if(MOD(ROW(),5)=0,B2,"") so that every fifth row has a value
Chart editor -> Setup -> Series -> Label point to the Annotation column
Chart editor -> Customize -> Series -> Data labels -> Type point to the Custom
Result:

How to create two histograms on one plot with shared axis?

I tried to plot arrival delay and departure delay columns separately, it's clear the distributions are different.
I would like to show them on the same plot, but whenever I try to do so, both plots became one identical shaped distribution although I'm plotting two different columns! What am I doing wrong?
Thank you for your help in advance.
You need a Departure Delay (bin) field. You can create one by selecting Departure Delay in the data pane on the left sidebar and selecting Create bin.
Once you have that new field, you can place it on the Columns shelf next to the other bin field and just put SUM([Number of Records]) on the Rows shelf — getting rid of both CNT() fields.
That should let you see both histograms.
To answer your question about why your previous approach yielded the same chart, you were binning data in both cases by the Arrival delay.
The CNT([xxx]) fields are misleading. That just counts the number of records that have a non-null value in the [xxx] field. If [xxx] always has a value, its equivalent to SUM[Number of Records]). The bin field is what matters.

Add a vertical line to Google Sheet Line Chart

I have a sheet with a line chart, now I'm trying to do something maybe very simple: I would like to add to this chart a vertical line using a value in a cell.
So I have this line chart
And a cell with the date 2016/01/01, I would like to have a vertical line through all the chart on the cell date
I can't figure out how to do it...
This is a copy of that sheet: https://docs.google.com/spreadsheets/d/1oeiwmeDT8pUVqBQvoE_cqk7mZxxvD5moZr41Vp4IN2I/edit?usp=sharing
I would like to show a vertical line using the "Purchase date"
I had the same problem and created a solution to overcome limitations of Google Sheets charts.
The main idea is to create an additional line in the chart, with only two points, both with the desired date. The value of the first point is 0 and the last has the maximum value of the Y axis. This way, the line always covers the entire height of the chart.
Screenshot of the Chart
Note that it is necessary to add two new values in the X axis (highlighted in blue on the sheet). Don't worry with the fact they are repeated. Google Sheets handles it correctly.
These values can be placed at the beginning of the lists. This way, it is possible to add new values at the end of them.
This solution can be viewed in: "[GoogleSheets] Dinamic Vertical Line in a Chart"
To change position of red line, just select a different value in "Purchase date" (yellow cell).
I made a merge of my first solution with the one suggested by dimo414 and created a new solution with two variations.
In the previous version of the spreadsheet, there were only two points to draw the vertical line.
In the new version, a third point were inserted to show intersection between the line and the real curve. A new column was also created, containing only a label for the new point.
The result is:
Theses changes can be seen in green background in sheets 'Dashboard_v2' and 'Dashboard_v3' of the SpreadSheet.
To determine coordinates of the new point, two approaches were used:
Search Purchase Date directly in the dataset (see sheet 'Dashboard_v2')
If the goal is to highlight only points of intersection that belong to the original dataset, it is just necessary to VLOOKUP() the date in the dataset.
Interpolate the two points immediately smaller and larger than the purchase date (see sheet 'Dashboard_v3')
Given the points [x1,y1], [x2,y2] and a value of x (where x1 <= x <= x2), its possible to find an interpolation point [x,y] with the following formula:
y=(y2-y1)*(x-x1)/(x2-x1)+y1
Although this formula is easy to implement, find the correct points to interpolate is more challenging and requires a bit of creativity.
At first, I thought of using a JS script to make things easier, but decided to use only builtin functions.
By the way, different approaches to find [x1,y1] and [x2,y2] are welcome.
To make things easier to understand, each point coordinate is determined in a different cell (see L2:M5) and the point of intersection is in L6:M7.
Of course, its possible to join all of them in just one cell, but I thought it would be harder to understand.
To close, one more detail: According to above definition, interpolation formula is valid only if (x1 <= x <= x2). Thus, both cells C2 and M6 have protections to limit the value of 'x'.
One way is to add a label to your x-axis.
For example, this is a chart that plots weight against date, with a label "Cheat Day" on 2021-07-21
For the data:
Date
Label
Weight (kg)
Weight Goal (kg)
2021-07-19
83.85
75
2021-07-20
84.55
75
2021-07-21
Cheat Day
83.8
75
2021-07-22
84.95
75
2021-07-23
83.75
75
Go to Edit the chart > Setup > Under X-axis > Click on ••• next to your "Date" column > Add labels > Select the column "Label" as your label.
Your Chart Editor > Setup should look like this:
you can have it like this, unfortunately not programmatically. the only way is to insert a line via Drawing and position it manually where needed.
spreadsheet demo
As best I can tell there isn't a way to add a vertical marker line to a chart in Google Sheets. One option that may be "good enough" in many cases is to "Add notes to a data point" and then use "Format data point" to make the point more visible. Here's an example, from your spreadsheet:
Unfortunately one limitation with this approach is you can only label a data point in the data set the chart is displaying. In your case the date you wanted to mark with a line isn't in the data set, so this won't work directly. You might be able to introduce a separate data series consisting of just that date and then add a note to that data point, but I haven't fiddled with it enough to make it work.

Where to set displayed data vs plotted data in Highcharts?

I am looking for a setting in Highcharts/stock that would allow me to apply a different format to displayed values of data, but not to the actual data as it is loaded into the series data. For example, we would like to plot y-axis data with precision up to 16 significant digits, and likewise, time values that use 6-8 sig figs. But that's not the precision we would like displayed in the tooltips, or other labels. However I am unable to find a way to format it without affecting both what is plotted and what is displayed. Here is an example of why this is a problem: let's say we have data points taken at .0001234s, .0001244s, .0001254s, and .0001264s, but we want to format the display of the time to ".0001" for all 4 data points. If we format it, then the "plotted" data ends up looking like it occurred at the same time-stamp, thus producing a stair-step look to our waveform.
I have looked at the custom functions that I can create to override tooltip display, but it doesn't appear that there is an easy way to make that very generic so that I can apply to all of the various chart instantiations (we use lots of different chart types), and that only covers tooltips; X-axis labels and Y-axis labels would also need separate functions for overriding those display values; there's possibly other places I haven't thought where the display might be affected as well. Is there any single, centralized place where the data points display value or format can be changed?
Example of stair-step appearance:
TIA
If you want to display various numbers (axis labels, tooltip, etc.) with various number of decimal places, you can use Highcharts.numberFormat function.
API Reference:
https://api.highcharts.com/class-reference/Highcharts#numberFormat
Example:
http://jsfiddle.net/eg0vepgq/

Highcharts moving average based on visible data only

So, I have a price time series I wrote a moving average for the prices of different retailers http://i.imgur.com/dn3EdM6.png . So far so good, but I want to only see the moving average of the visible retailers. For example, here I have only one shop shown, but the moving average is calculated on all of them. http://i.imgur.com/ZpK5gsG.png Is it possible to make it to dynamically change? Maybe reload the graph or something?
I made an example based on my comment above.
This example does not calculate a moving average - I wrote a simple function to calculate the overall average for the sake of simplicity.
The purpose of the example is to demonstrate how to do it on legendItemClick, making use of only the visible series.
Example:
http://jsfiddle.net/jlbriggs/gejgquxh/

Resources