how to compare each record with the median of the whole set of data in tableau - tableau-api

I have a calculated field for the median, but I want to filter on each record, compare it with the median. The issue is when filtered, the median becomes the record itself. how can I fixed the median?
Thanks.

If you are using the latest Tableau, then you can use LOD calculation as advised by Alex. In your case, simply wrapping it in {} should do the trick: {MEDIAN([Sales])}
This will configure the calculation to ignore the effects of the filter. But if your worksheet is complicated, then more modifications to the formula might be required.
If you are using older versions of Tableau, then there is a more complicated workaround with table calculations and special filters to achieve the same result.

Related

Why does Tableau LOD calcs display a range of values rather than a sum-total?

I get this problem often where I have a LOD calculation but instead of a single total value, I get the high and lows of the data range.
Here is my LOD calc:
But, the numbers it displays is a range of the lowest value to the highest value. I do not understand this. I have this problem often.
The way I tend to deal with this situation is to wrap the calculation in WINDOW_SUM().
WINDOW_SUM(SUM([LOD Period Demand]))
Put the window_sum calc on the Detail shelf, where you'll be able to add it to the title for your summary.
If i interpret it correct, then your DemandSalesNet is at the level of Site, Whse and Period. Means unique on these three variables. Correct?
Try Using "Fixed" instead of using "Include".
I hope that will work.

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

How to avoid aggregation of measure values in tableau

I'm trying to retrieve and analyze records from SQL server. Whenever I drag the measure values to rows field it gets auto aggregating itself in tableau.
I dont want this aggregation to be done since my values doesn't make sense when it gets agregated.
Is there a solution to remove this aggregation in tableau ?
Thanks
Yes, you can avoid aggregating values. However, your problem isn't that you are aggregating your values, your problem is that you are treating dimensions as measures.
To fix this you can convert Year from a measure to a dimension:
Of course, if you want to disaggregate the measures then you can always do that too:

Multiply all rows in a Tableau table chart

This seems pretty simple, but I can't seem to find a way to do this.
I need to multiply all rows in a chart - or all columns, whichever is easiest. AKA. I am looking for something like the product() function in Excel.
Any ideas on how to accomplish this?
EDIT: Row values may change, so this needs to be a dynamic calculation. Like a function to aggregate all values into a product of the values.
A calculated field can be created with: sum([Sales])*PREVIOUS_VALUE(1)
This gives the running product. Then, that field can be inserted into the table.
You can certainly create a calculated field that will multiply various columns together. Something along the lines of [Column1] * [Column2] * [Column3] will generate a new calculated measure that is the product of all three columns.
That being said, if you're doing that much data manipulation within Tableau, you should probably be giving some hard thought as to why that's necessary. While calculations are certainly possible and new Tableau 9 features such as level of detail functions make doing calcs on measures not present in your viz easier, Tableau is primarily a data presentation layer. Data manipulation apart from simple calcs and pivot/unpivot operations should be done upstream. Doing advanced manipulations within Tableau, while sometimes/often possible, can be very hard to debug and reproduce.

Aggregate bins in Tableau

I want to aggregate bins in tableau.
See the following figure:
I want to aggregate (merge) the NumberM from 6 untill 16 in one category. 5+/(6 and higher) for example and sum the values of 6-16 in that category. I think this can be done with a few simple clicks but I am not able to manage.
Thanks in advance,
Tim
There are several ways to classify data rows into different groups or classes: each with different strengths.
Create a calculated field As emh mentioned, one approach is to create a calculated field to assign a value to a new field indicating which group each data row belongs to. For the effect you want, the calculated field should be discrete (blue). If your calculation doesn't return a value for in one case, e.g. an if statement without an else clause, then the field will be null in that case which is a group in itself. This is a very general approach, and can handle much more complex cases. The only downsides are the need to maintain the calculated field definition and that the cutoff values are hard coded and by itself can't be changed dynamically via a control on the view. BUT those issues can by easily resolved by using a parameter instead of a numeric literal in your calculated field. In fact, that's probably the number one use case for parameters. If you think in SQL, a discrete field on a shelf is like a group by clause.
Use a filter If you only want a subset of the data in your view, e.g. data rows with NumberM in [6, 16] then you can drag the NumberM field onto the filters shelf and select the range you want. Note for continuous (green) numeric fields, filter ranges include their endpoints. Filters are very quick and easy to drop on a view. They can be made dynamically adjustable by right clicking on them and creating a quick filter. Its obvious from the view that a filter is in use, and the caption will include the filter settings in its description. But a filter doesn't let you define multiple bins. If you think in SQL, a filter is like a where clause (or in some cases using the condition tab, like a having clause)
Define histogram bins If you want to create regular sized bins to cover a numeric range, such as values in [1,5], [6,10], [11-15] ..., Tableau can create the bin field for you automatically. Just right click on a numeric field, and select Create Bins.
Define a group Very useful for aggregating discrete values, such as string fields, into categories. Good for rolling up detail or handling multiple spellings or variants in your data. Just right click on a field and select Create Group. Or select some discrete values on an axis or legend and press the paperclip option. If you then edit a group, you'll see what's going on. If you think in SQL, a group is like a SQL case statement.
Define a set Another way to roll up values. The definition of a set can be dynamically computed or a hard coded list of members. Both kinds are useful. You can combine sets with union, intersection, set difference operators, and can test set membership in calculated fields. Sets are useful for binary decisions, rows are divided into those that are members of the set and those that are not.
Filters, sets, groups, calculated fields and parameters can often be combined to accomplish different effects.
Most if not all of these features can be implemented using calculated fields, especially if the business rules get complicated. But if a filter, bin, group or set fits your problem well, then it's often best to start with that, rather than define a calculated field for each and every situation. That said, learning about the 4 kinds of calculated fields really makes a difference in being able to use Tableau well.
You can do this with calculated fields.
Go to: Select Analysis > Create Calculated Field.
Then use this formula:
IF NumberM > 5 THEN "OVER 5"
You can then use that calculated field as a filter on the worksheet in your screenshot.
Answering my own question:
With Tableau 9 this can be easily done with the increased flexibility of the level of detail expressions (LOD). I can really recommend this blog on that subject and many more Tableau functions.