Mondrian: Filter greater than or less than in a Time Dimension - date

I am having difficulty filtering a time dimension.
I have a Time Dimension with a date level that is derived from sql function -> DATE( TimeStampBegin )
I want to filter where the date is greater than 2014-03-03:
select NON EMPTY [Users].[Trial].Members ON COLUMNS,
NON EMPTY[Problem Areas].[Fridges] ON ROWS from [Search]
WHERE (Filter([Time].[Date].Members, [Time].[Date].CurrentMember > [2014-03-03]))
The result set I get is:
Axis #0:
{[Time].[2014-02-28]}
{[Time].[2014-03-04]}
{[Time].[2014-03-10]}
{[Time].[2014-03-13]}
Axis #1:
{[Users].[ILearnTrial2014]}
Axis #2:
{[Problem Areas].[Fridges]}
Row #0: 161
As you can see, the Time member returned includes 2014-02-28 which is not greater than 2014-03-03.
If I change to 2014-03-03 I get:
Axis #0:
{[Time].[2014-02-28]}
{[Time].[2014-03-10]}
Axis #1:
{[Users].[ILearnTrial2014]}
Axis #2:
{[Problem Areas].[Fridges]}
Row #0: 93
As you can see there is no relationship between the greater than date and what Time].[Date] members are returned.
I am also trying [Time].[Hour] and the results show the same inconsistencies.
Can anyone help?
EDIT
I'd like to pass on the solution to my problem in the spirit in which these forums are supposed to work.
Thanks to Luc for his pointless and unhelpful comment yesterday.
For anyone interested, filter for the current member name as follows, Filter([Time].[Date].Members, [Time].[Date].CurrentMember.Name > "2014-03-03").

Related

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.

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

Issue in viewing double values

I am having an issue with viewing double data in matlab console. Actually, I am importing a matrix from my data file. The value of a particular row and column was 1.543 but in the console when I use disp(x) where x is the matrix imported, it is showing as 1.0e+03 * 0.0002. However, when I try to access that particular element in the matrix using disp(x(25,25)) where 25 and 25 are the row and column numbers it is showing to be 1.543. So I am confused. Any clarifications. It is just that when I print the whole matrix it is showing as 1.0e+03 * 0.0002.
The following command should fix it. It is only a display issue, the precision of the actual values in the matrix are not affected:
format shortG
That happens due to high dynamic range of your data.
Try for example :
x = [10^-10 10^10];
disp(x);
The result is:
1.0e+010 *
0.0000 1.0000
It looks like the first value is zero, but it isn't. It is almost zero compared to the second one. That is not surprising. Try to add to the big value the small one, and subtract, and you get zero. That is due to floating point arithmetic.The following expression is true
isequal( (x(1)+x(2)) - x(2) , 0)
What can be done?
1) A really high dynamic range can cause troubles in any kind of computations. Try to understand where it came from, and solve the problem in a broader context.
2). You can try to set
format long
It can improve the situation visually for some of the cases.

matlab: grouping variables for gscatter

I'm a complete Matlab newbie, so please bear with me :) I'm using my friend's vague instructions, so I don't if they are correct.
I have variable named m12 (imported form an .xls file), which is an 61x3 array. No labels.
The first column contains leverages, the second standardised residuals for the training (first 46 rows) and validation (remaining 15 rows) sets of a PLS model.
I want to group those first two columns, so that the training set is represented by blue 'X', and validation set by red 'O', so I put 46 rows of '1's and next 15 rows '2's in the third column.
My friend told me to simply type:
group(:,3)
gscatter(m12(:,1), m12(:,2), group,
'br', 'xo')
but when I type
group(:,3)
I get an "??? Undefined variable group." error.
Can anyone help me?
Just write
group = m12(:,3);
instead of your first line.
This way, you're defining a vector group that contains all the entries of the third column of m12, i.e. your grouping variable.