Detecting patterns in data with Tableau - tableau-api

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.

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.

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 - Dividing two calculated fields, getting wrong result of 1

I've been ripping my hear out trying to figure out why this is happening, any help would be very much appreciated!
I'm trying to divide the result of a calculated field by another calculated field in order to get a percentage ("X% of transactions were at or below SLA" essentially). Not sure if the problem is how I'm calculating the two fields, or this new calculation I'm using.
Here is the calculation I'm using: sum([CALC1]) / ([CALC2]) --I'm getting a result of 1 using this, but am expecting something like .982.
CALC1: IF [Total Time (seconds)] > 180 THEN 1 ELSE 0 END
CALC2: COUNT([Trans Id])
I thought it would make sense to add this in the answers portion, even though the correct answer is listed in the comments.
The issue is with how you are displaying the answer. Right click on the measure in the left hand pane and scroll down to "default properties". Go to "Number format" and adjust to the desired number of decimal places.

Tableau 8.2 - how to get max and min from % difference values on table?

I'm facing problem in getting the max % and min % from a table containing % difference values.
Year-----A----------B---------C---------D---------Max %----Max Type----Min %----Min Type
2012
2013---4.30%---4.42%---4.34%---4.38%----4.42%---------B-----------4.30%---------A
The table above shows the % difference in sales from previous year. Thus 2012 shows no % (because there's no 2011). I used table calculation to compute the % difference, i.e. "Percent Difference From", compute using "Table (Down)" and "Previous".
The last four columns are what I'm having trouble doing. I want to get the max % and min % and also the corresponding types. I'm not trying to add the four columns to the existing table, but to get the correct results, as my ultimate goal is to display that results on the dashboard, i.e. on my dashboard, I want to display the highest % and its corresponding type; similarly the lowest % and its corresponding type. For example: on my dashboard, I want to display:
Highest % and type: 4.42% B
Lowest % and type: 4.30% A
So, I need to have the correct formulas to get the max % and min % and their types. These are what I did:
I tried to use WINDOW_MAX and WINDOW_MIN to display the max % and min % on the table but got funky wrong results.
1) I first get the formula in calculating the % difference from the "Customize" button from "Edit Table Calculation" window of SUM([Sales]): (ZN(SUM([Sales])) - LOOKUP(ZN(SUM([Sales])), -1)) / ABS(LOOKUP(ZN(SUM([Sales])), -1))
Then I created a calculated field of the above formula. I named the calculated field "Percent-Diff".
2) I created another calculated filed (named "Max % Difference") using the formula: WINDOW_MAX([Percent-Diff]). But it shows strange results. See image below. I don't know why it gives me 2.78% and 2.91% for 2012 and 2013 respectively. It should be 0% and 4.42% for 2012 and 2013 respectively. Something is not correct.
If it is just SUM([Sales]) instead of % difference, then I get the correct result of showing the max sales using the formula WINDOW_MAX(SUM([Sales])).
3) Also I don't know how to get the corresponding type. I tried using the formula: IF [Max % Difference] = [Percent-Diff] THEN ATTR([Product Type]). But it returns:
NULL
B
I'm not sure if the formula is correct. It looks correct on the result (i.e. "B" is correct), except that it also shows a NULL value which I don't know why. I think it's because I didn't include the ELSE part in my IF formula? But why the NULL value is shown as the first value? I want the formula to return just one value, "B". So, how to only just show "B"?
I've posted twice the problem in tableau forum, but as of now, nobody has answered my problem. I believe that my formulas are incorrect. So, if anyone here can correct the formulas to get the max % and min % from % difference values and also to get the corresponding type, then it'd be very much appreciated. Thanks a million!
It's hard to tell not knowing how your database looks like (as you didn't explicitly presented it, but I can try to infer based on the clues you left on your post). But I could reproduce something like you said using the Sample - Coffee Chain Database, and it worked out well, calculated yoy sales increase by product and then window_max of that.
What you're probably missing is the partitioning. I suggest avoiding using Table or Pane to create the partitions in more complex situations (as it will work only in that specific arrangement of fields), but rather use the dimensions to partition it.
So, your [Percent-Diff] field should be compute using [Date], and your [Max % Difference] should be compute using [Product Type]. IMPORTANT, for [Max % Difference], when you go to Edit Table Calculation, you'll have to choose the Compute using for [Percent-Diff] as well (you can choose on the top of the window)
Your formula to find which type is the max (or min) is also correct (and should only respect the partitions). Nevertheless, it is very hard to have the exact output you're expecting.
What I would do is to create 2 spreadsheets (and later combine them in a dashboard).
The 1st would be what you already got (Each product [Percent-Diff]
The second one I would change your formula (3) to just [Max % Difference] = [Percent-Diff], and use it as filter (filtering only true). I would drag both Date and Product to the sheet (you choose if you want it on columns, rows, or just detail) so I can use them to partition the table. And drag [Max % Difference] to be visualized.
That way you'll only see the product that is the max, and how much is that max.
Hope it helps

How do I achieve a multi-series line chart in Crystal Reports?

This relates to my How do I achieve a pivot report in Crystal Reports for Visual Studio? The data is the same, but they want a line chart as well.
So, my data is {datetime}, {car-id}. The X -axis of the chart must show the hour of {datetime}, the Y axis the number of cars that entered the park at that hour, and I must have seven data series, lines, one for each day of the week. So, e.g. the x/y point on the green line shows that on Wednesday, at hour x, y cars entered the car park.
Common sense tells me that I can kludge this by transforming the data source so that each day has its own column in a table, a table like this:
DateTime
WeekDay
CarCount
Yet the Crystal line chart doesn't seem to support more than one column, so there must be a different and better way of doing this. The weekday is part of {datetime} after all.
How can I achieve this chart? I am a rank amateur at charting, and Crystal's idiosyncrasies really aggravate my lack of skills and experience in this area.
It's not obvious how to get multiple series to show up properly.
First, create a formula that will extract the day of week from the datetime: dayofweek({datetime}) and then create another that will extract just the hour: hour({datetime}).
From there, insert a chart from scratch and make the following settings in the Chart Expert
Select "Line" under the Type tab
Under the Data tab, select "On change of" and select your {#HourOfDay} formula first. This will create each hour as a point on the X-axis.
In that same spot, also insert the {#DayofWeek} formula. This will create a new line
for each day of the week. This is, in my opinion, the non-obvious part.
Finally, to pick your Y-axis values,
select {car-id} where it says "Show value(s)". It should default to
the count summary of that field.
(Note: in the screenshot below, you would just replace {Customer.Customer_Name} with {car-id}
I had this issue for 5 years and finally solved it. I have a XY chart with multiple series.
Everything needs to be in a formula.
The graph should be in the report header section of a subreport. The sub report generates the X Y data like this:
Series X Y
Ser1 2020 1
Ser1 2021 2
Ser2 2020 0
Ser2 2021 1
For me I have as series "Energy" ie 6, 9, 12 etc.
Then I have a date/time and a measurement.
On change of (Energy formula)
Show Values
#1 DateTime (convert this to int ie 2000.9 for 9/2000) - dont summerize
#2 Measurement (number) - dont' summerize
Then you can do the color highlighter to capture your series (6 is red etc).
The legend won't work - can't figure out that yet.