How to set filter value by parameter field in tableau? - tableau-api

I've created a parameter A and calculated field B to choose filter (between C and D) based on A.
How can I set filter value, when make a choice in B?
Something like:
IF B==C then C = 'enabled'
IF B==D then D = 12
Field C and D have different dimensions, so, making choice in B and then switching to another value
I got an empty dashboard before setting any value in the filter.
When I choose Year to date filter and switch to ENABLE I see my plots, but when changing to By month option nothing selected, and to fix any visualization I need to choose values again. When I switch Year to date this story returns.
When I choose Year to date filter and switch to ENABLE I see my plots
but when changing to By month option nothing selected, and to fix any visualization I need to choose values again
This is the way how I calculate the chosen filter

Related

Tableau - Toggle between 2 measures by single select filter on one basic text grid

looking to have a basic text grid by month by product, and then have a single filter on only 2 of the measures. For example:
Measures Filter
------------------
[ ] Sales <-- only show this
[X] Quantity <-- and this as options
[ ] Interest (don't show in filter)
[ ] Fee ( don't show in filter)
JAN | FEB | MAR | APR | MAY | etc ...
products
ITEM1 x x x x x
ITEM2 x x x x x
ITEM3 x x x x x
So the user can basically toggle between Sales or Quantity, and whichever they click on will fill out the x by month.
I was able to get this to work for everything except only showing the 2 measures I want to filter for. It only shows all measures for me in the filter and I can't figure out how to hide them.
What I did was
Drag Date to columns
Drag Product and MeasureNames to Rows
Can someone please help me on getting this correct? Any help or guidance is appreciated!
This is not the correct use case of FILTERS. Filters are normally used to filter (read subset) the data (read rows). Say for example If your dataset has 1000 rows/records and you want some report/visual/aggregation on say 500 rows (based on some criteria of course) you have to filter the data. For selection of argument (user based) in some report/viz, etc. Parameters are used.
Your desired example output is also a perfect case of use of Parameters. You may proceed as follows-
Step-1 Create a parameter (say parameter 1) with values as SALES and QUANTITY.
Step-2 Create a calculated field (say CF1) with the following calculation
CASE [parameter 1]
WHEN 'SALES` THEN [sales]
WHEN 'Quantity' then [Quantity]
END
Note: It is assumed that your field/column names in dataset are sales and Quantity
Step-3 Build your view (Crosstab here) with
months on Columns shelf
products on rows shelf
CF1 on text in Marks card (alternatively just double click it)
Choose measure for aggregation of CF1 as desired (default will be sum)
Step-4 right click paramter 1 and click show parameter. (select desired measure for aggregation in crosstab)
VOILA your desired view is complete. Good luck.
There is another options to add to Anil's good suggestion. You can also use Measure Names as a filter. Hide all measures apart from those you want in the filter, then put Measure Names on the filter shelf.
However, this means you can't use the hidden measures from the data source elsewhere, which can be a deal breaker. Duplicating the data source is a way around that limitation.
But if you only want to show the 2 measures and are happy with single select, then choosing the measure by parameter is the better option, as Anil suggests.

Detecting patterns in data with Tableau

i'm totally new to Tableau but that is what I could potentially use at the workplace, so asking this question to decide if its worth it.
I've a monthly values dataset and I'd like the tool (Tableau) to generate a report to point out anomalies - the ones i have in mind right now are:
1) same data value for x months in a row
2) data value is 0
3) 5 parameters been reported last 3 months and all of sudden only 4 are reported
Is this possible in Tableau?
You can certainly do this. The below is a general example for doing anomaly detection (one standard deviation outside of mean) but you can modify the calc to fit your criteria. If you place your date field in the column position and your metric, lets say Sales, in the row position you can then create this calculated field to label the anomalies.
IF SUM([Sales]) < (WINDOW_AVG(SUM([Sales])) – WINDOW_STDEV(SUM([Sales]))) THEN “Bad
Anomaly”
ELSEIF SUM([Sales]) > (WINDOW_AVG(SUM([Sales])) + WINDOW_STDEV(SUM([Sales]))) THEN
“Good Anomaly”
ELSE “Expected”
END
You can then place the new field on your color mark to highlight each of the results.

A filter to apply only if only one item from two other filters are selected

I have two filters for WeekNumber and Employee (name). I also have a column that shows the SUM of hours the employee has worked. Let us call it SumHours.
What I want to do is to specify the employees who have overworked, which is
if the number of weekly hours is more than 38.
If the condition applies I'd like to highlight them by adding a background color to their row.
Adding the above filter to the entire table is not a problem. What I want to do is for this filter to appear only if (1) one week and (2) one employee have been selected. Because otherwise the calculated field will highlight the employee if they have overworked in average.
How can I create a condition in my calculated field so that a condition is checked in two different places? I have found the SIZE() function but then we should also select the option Compute Using... to assign it to a specific filter. But apparently one cannot do that to two filters.
If I understand your setup correctly, I think a level-of-detail calculation might do the trick. This is pseudo-code, you will need to adjust for your dimension names. With LOD, you are getting the value of the hours worked per employee and week, regardless of which dimensions you have in your rows or columns.
if {FIXED Employee, WeekNumber : sum(HoursWorked)} > 38 then "Highlight" end
Then add this calculated field on the color marks card.
More about level-of-detail calcs can be found in Tableau's online help.

Advanced box plots in Tableau

I am currently exploring Tableau and I wonder if it can do the following.
Let's say I have a table with two columns, A and B. Let's say A can attain discrete values from a small set (maybe 10 different values), while B has continuous values. I would like to plot a box plot where on the x-axis are the 10 possible values of A, and on the y-axis the box plots. Each box plot shall contain values from B for a given value of A.
In case I have not made myself clear enough, here is an example. Consider data containing average temperature on each day within one year, labeled by week days. That is, we have 365 pairs (A, B), where A is a value between 1 to 7 (day of week), and B is the temperature. I would like to have 7 box plots, each containing data for the particular day week. (To prove that on Mondays there is always bad weather :))
Changing the problem slightly to assume the columns are named Date and Temp, and that Date is a real date with a month, day and year. On the data pane (left margin), make sure the Date field is a discrete (blue) dimension with datatype date (not string).
Drag Temp to rows, make sure it is a continuous measure. I would choose the aggregation function AVG instead of Sum for temperatures.
Change the mark type from automatic to circle, and then drag Date to the detail shelf. Right click on the Date pill you just dropped and choose Exact Date.
Change to the Analysis table and drag in box plot from the Summary section. Format to taste.
To get one column per weekday, drag Date onto the columns shelf. Right click on the Date field on the columns shelf and choose Weekday from the context menu (submenu)

Tableau Calculated Field Filtering

I am struggling with Custom Filter using Calculated Field.
Below is the screenshot of the same visualized chart.
What I am struggling is to create a filter where I can give a scale of Correlation, example - I want to show all the age groups and Ethnicity where the Correlation value is between 0.6 and 0.9
I am able to bring in one Measure Value and as you can see, the filter slider is there. But I need that filter to work on all the fields and not just one value. Like a Universal Slider for all the values.
Please help.
You cannot set one filter to be used on several measures. However what you can do is create two parameters and use them to filter each measure in relation.
create 2 parameters minCorrelation and maxCorrelation with values between 0 and 1 and stepsize of 0.1 (or whatever granularity you need)
open one of your filters and go to formula, use a custom formula like [0-17] > [minCorrelation] AND [0-17] < [maxCorrelation]
repeat that for every measure and the filter will adjust when you change the values for your parameters.